This API is provided for front-end and it built on Express.js framework in Node.js and MySQL database for Simple Twitter.
More details of API, please refer this API document created through postman.
- Node.js
- Express
- mysql2
- Sequelize
- Passport(Local & JWT)
- bcryptjs
- jsonwebtoken
- Clone this project to local
$ git clone https://github.com/wenliangsu/twitter-api-2023.git
- Install all dependencies in project file
$ npm install
- Setting database for development and test. Database name need to be same with config/config.json
DROP DATABASE IF EXISTS ac_twitter_workspace;
CREATE DATABASE ac_twitter_workspace;
DROP DATABASE IF EXISTS ac_twitter_workspace_test;
CREATE DATABASE ac_twitter_workspace_test;
- Create Table through migration files in test and development environment separately
$ export NODE_ENV=test`
$ npx sequelize db:migrate
$ export NODE_ENV=development
$ npx sequelize db:migrate
- Create a
.envfile and refer.env.exampleto set environment varaible
IMGUR_CLIENT_ID = Your Client ID
IMGUR_CLIENT_SECRET = Your Client SECRET
IMGUR_REFRESH_TOKEN = Your Refresh Token
JWT_SECRET = Your JWTSecret
PORT = Your Port
To make sure all features are working properly, run the following command. If there is any test errors, make sure you setup as above.
$ export NODE_ENV=test
$ npm run test
- Create seed data through seed files before server start.
$ export NODE_ENV=development
$ npx sequelize db:seed:all
- Start server. If successful,
Example app listening on port 3000!will show in terminal
$ npm run start
- If you have install
nodemon, you could run the followin command
$ npm run dev
- If you want to stop server running.
Ctrl + C