Configs

Configs

The first thing to do is get your configs set up. The database connection is all you really need.

{
"port": 3030, // api port
"database": {
"dialect": "mysql",
"user": "", // db username
"password": "", // db password
"host": "", // db host
"database": "" // name of the database
},
"default_from_email": "hello@noco.io", // for emails!
"sendgrid": "", // to send emails!
"auth": {
"allowed_origins": [], // an array of allowed origins like ["http://localhost:3000"]
"issuer": "noco", // anything will do here
"audience": "noco", // anything will do here for,
"expiresIn": 10000 // number of seconds the JWT is good for.
},
"s3": {
"key": "",
"secret": "",
"bucket": "",
"region": "",
"s3ForcePathStyle": true,
"signatureVersion": "v4",
"endpoint": ""
}
}

If you need a simple local mysql database you can use docker to quickly set one up.

docker run -ti -p 3306:3306 \
-v $(PWD)/sql:/var/lib/mysql \
-e MYSQL_ROOT_PASSWORD=password \
mysql:5.7

You'll then need to use something like Sequel Pro to create a database to connect to. Let's say you create a data

Then your local configs could look something like this.

"database": {
"dialect": "mysql",
"user": "root",
"password": "password",
"host": "0.0.0.0",
"database": "test"
},

If you want to use another one of Sequelize's databases, you'll need to install the adapter yourself. Take a look at their docs https://sequelize.org/master/manual/getting-started.html‚Äč

Next up it's time to install the node modules

npm i

After your node modules are installed, you can run npm run docsto generate your own API documentation.

You're then ready to run your API with npm run dev

# Successful output of your api once you've set your configs
API on port 3030!
mysql connected
bootstrapped api key!

If you head over to http://localhost:3030 you should see your documentation. It will look something like this:

your beautiful new docs!