A Simple REST API app based on Express and PostgreSQL
- JWT Authentication
- Structured Folder for better architecture
- Using Objection.js
Open your working folder and run command below on terminal
git clone https://github.com/kwaiks/express-api-js-starter-kit.git
Move to your cloned directory
cd express-api-js-starter-kit
Install packages using npm
npm install
or yarn
yarn install
Edit .env.example file then rename it to .env Below are the configurations
NODE_ENV = development
PORT = 3000
DB_NAME = YOURDBNAME
DB_USER = YOURDBUSER
DB_PASS = YOURDBPASS
npm run start
Create new Database named express
sudo -u postgres psql
postgres=# create database express;
To be able using example data, install knex globally
npm install knex -g
Run command
npm run migration MIGRATION_NAME
Then open newly created file on src/db/migrations
If you're done, you can run
npm run migrate:latest
Run command
npm run seed SEED_NAME
Then open newly created file on src/db/seeds
If you're done, you can run
npm run seed:run
You could modify DB Configuration that can be found in src/config/knexConfig.js
Below are the configurations
client: "pg",
connection: {
database: process.env.DB_NAME,
user: process.env.DB_USER,
password: process.env.DB_PASS
},
pool: {
min: 2,
max: 10
},
migrations: {
directory: __dirname + "/db/migrations",
tableName: "express_js_migrations"
},
seeds: {
directory: __dirname + "/db/seeds"
},
...knexSnakeCaseMappers()
You could import postman.json
for postman collection to test this app with example data