10000 GitHub - oppytut/express-api-kit: A Express.js Based API Project Kit
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

oppytut/express-api-kit

Repository files navigation

express-api-kit

A express.js based API project kit.

Installation

Clone project
git clone https://github.com/oppytut/express-api-kit.git && cd express-api-kit
Install packages
npm install
Run

For development mode with Webpack watch:

npm run dev

For production mode:

npm run start
Access http://localhost:8000 through the browser

Configuration

The configuration files are in the configs directory.

Database
const username = 'mz_petuahUser';
const password = 'sandimz_petuahUser';
const host = '127.0.0.1';
const port = '17027';
const name = 'mz_petuah';

A name variable for database name.

Server

Server port can be configured.

const port = 8000;
CORS (Cross-Origin Resource Sharing)

Clients that can access the API can be configured.

const whiteList = ['http://localhost:3000'];

const corsOptions = (req, cb) => {
  const options = {
    origin: whiteList.indexOf(req.header('Origin')) !== -1,
    optionsSuccessStatus: 200,
    methods: ['GET', 'POST', 'PUT', 'DELETE'],
  };
  cb(null, options);
};
JWT (JSON Web Token)

JWT secret code can be configured.

const jwtConfig = {
  secret: 'g0r3ng4nH4ng4t',
};
Bcrypt

Bcrypt salt rounds can be configured.

const bcryptConfig = {
  saltRounds: 10,
};

Demo

A demo can be accessed on https://exa.mazovi.com/api/ ... (GET/POST/PUT/DELETE).

Todo

  • Configure Git, NPM, and Eslint (airbnb)
  • Add and Configure Webpack (auto reload)
  • Add GraphQL and Apollo Server
  • Add Redis
  • Publish helpers to NPM
  • Testing

About

A Express.js Based API Project Kit

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0