Skip to content

wenliangsu/twitter-api-2023

 
 

Repository files navigation

Simple Twitter API

This API is provided for front-end and it built on Express.js framework in Node.js and MySQL database for Simple Twitter.

API Document

More details of API, please refer this API document created through postman.

Built with

  • Node.js
  • Express
  • mysql2
  • Sequelize
  • Passport(Local & JWT)
  • bcryptjs
  • jsonwebtoken

Getting Start

Installation

  1. Clone this project to local
$ git clone https://github.com/wenliangsu/twitter-api-2023.git
  1. Install all dependencies in project file
$ npm install

Environment Setup

  1. 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;
  1. 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
  1. Create a .env file and refer .env.example to 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

Test

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

Usage

  1. Create seed data through seed files before server start.
$ export NODE_ENV=development
$ npx sequelize db:seed:all
  1. Start server. If successful, Example app listening on port 3000! will show in terminal
$ npm run start
  1. If you have install nodemon, you could run the followin command
$ npm run dev
  1. If you want to stop server running.
Ctrl + C

Contributor

About

ALPHA Camp | 學期 3 | Simple Twitter | 自動化測試檔 (前後分離組)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%