A simple twitter API project built with Node.js, Express, and MySQL.
Please check our API Docs for more information
The following instructions will get you a copy of the project and all the setting needed to run it on your local machine.
Clone this repository to your local machine
$ git clone https://github.com/smallpaes/simple-twitter-express-starter.git
Create database via MySQL Workbench
Run the following code
drop database if exists ac_twitter_workspace;
drop database if exists ac_twitter_workspace_test;
create database ac_twitter_workspace;
create database ac_twitter_workspace_test;
1. Enter the project folder
$ cd simple-twitter-express-starter
2. Install packages via npm
$ npm install
3. Create .env file
$ touch .env
4. Store API Key in .env file and save
JWT_SECRET=<YOUR_Client_ID>
5. Edit password in config.json file
/config/config.json
"development": {
"username": "root",
"password": "<YOUR_WORKBENCH_PASSWORD>",
"database": "ac_twitter_workspace",
"host": "127.0.0.1",
"dialect": "mysql"
},
"test": {
"username": "root",
"password": "<YOUR_WORKBENCH_PASSWORD>",
"database": "ac_twitter_workspace_test",
"host": "127.0.0.1",
"dialect": "mysql",
"logging": false
},
6. Run migration
run the following code in the console
$ npx sequelize db:migrate
$ NODE_ENV=test npx sequelize db:migrate
7. Activate the server
$ npm run dev
8. Find the message for successful activation
> Example app listening on port 3000!
You may visit the application on browser with the URL: http://localhost:3000
1. Modify scripts (Only for Widows users using console emulators like Cmder or bash)
/package.json
"scripts": {
"start": "node app.js",
"dev": "nodemon app.js",
"test": "set \"NODE_ENV=test\" && mocha test/*/*.js --exit --recursive --timeout 5000"
},
2. Run test for the project
$ npm run test