Skip to content

Commit

Permalink
Merge pull request #205 from bc-chaz/APPEX-628
Browse files Browse the repository at this point in the history
Appex 628
  • Loading branch information
bc-chaz authored Sep 20, 2023
2 parents 7434552 + aba4925 commit 261fec6
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 7 deletions.
4 changes: 3 additions & 1 deletion .env-sample
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ FIRE_API_KEY={firebase key}
FIRE_DOMAIN={firebase domain}
FIRE_PROJECT_ID={firebase project id}

# If using mysql, enter your config here
# If using mysql, You can use a database URL or enter multiple configuration variables. Comment out the variables you don't use by adding the `#` character to the beginning of the line.

# DATABASE_URL={mysql://db_address}

MYSQL_HOST={mysql host}
MYSQL_DATABASE={mysql database name}
Expand Down
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

This starter app includes all the files necessary to get started with a basic, hello world app. This app uses NextJS, BigDesign, Typescript, and React.

## Running the app
## Running the app in development

To get the app running locally, follow these instructions:

Expand Down Expand Up @@ -82,3 +82,14 @@ npm run dev
> If `ngrok` expires, update the callbacks in steps 4 and 7 with the new `ngrok_url`. You can learn more about [persisting ngrok tunnels longer (ngrok)](https://ngrok.com/docs/getting-started/#step-3-connect-your-agent-to-your-ngrok-account).
11. Consult our developer documentation to [install and launch the app](https://developer.bigcommerce.com/api-docs/apps/quick-start#install-the-app).

## Production builds

In production, you must build and run optimized version of the code. Use the following commands to get started:

> When you run the `start` script, specify a port number using the `-p` flag. Otherwise, the process will fail.
```shell
npm run build
npm run start -p 3000
```
8 changes: 4 additions & 4 deletions lib/dbs/mysql.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createPool, PoolOptions } from 'mysql2';
import mysql, { PoolOptions } from 'mysql2';
import { promisify } from 'util';
import { SessionProps, StoreData } from '../../types';

Expand All @@ -10,10 +10,10 @@ const MYSQL_CONFIG: PoolOptions = {
...(process.env.MYSQL_PORT && { port: Number(process.env.MYSQL_PORT) }),
};

// For use with Heroku ClearDB
// For use with DB URLs
// Other mysql: https://www.npmjs.com/package/mysql#pooling-connections
const dbUrl = process.env.CLEARDB_DATABASE_URL;
const pool = dbUrl ? createPool(dbUrl) : createPool(MYSQL_CONFIG);
const dbUrl = process.env.DATABASE_URL;
const pool = dbUrl ? mysql.createPool(dbUrl) : mysql.createPool(MYSQL_CONFIG);
const query = promisify(pool.query.bind(pool));

// Use setUser for storing global user data (persists between installs)
Expand Down
2 changes: 1 addition & 1 deletion scripts/db.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const MYSQL_CONFIG = {
...(process.env.MYSQL_PORT && { port: process.env.MYSQL_PORT }),
};

const connection = mysql.createConnection(process.env.CLEARDB_DATABASE_URL ? process.env.CLEARDB_DATABASE_URL : MYSQL_CONFIG);
const connection = mysql.createConnection(process.env.DATABASE_URL ? process.env.DATABASE_URL : MYSQL_CONFIG);
const query = util.promisify(connection.query.bind(connection));

const usersCreate = query('CREATE TABLE `users` (\n' +
Expand Down

0 comments on commit 261fec6

Please sign in to comment.