ruanmartinelli / api-starter

:green_book: node.js express api
MIT License
13 stars 0 forks source link

api-starter

Standard - JavaScript Style Guide Build Status codecov Greenkeeper badge

Everyone needs an API these days, right?

Requirements

Dependencies

Folder structure

Folders look like this:

.
├── src
│   ├── api         # API modules (i.g. user, auth, etc.) 
│   ├── db          # Database connection module
│   ├── job         # Recurring jobs
│   ├── middleware  # Express middlewares
│   ├── migration   # Database migrations
│   ├── model       # Application model classes
│   ├── seed        # Database seeds
│   ├── schema      # Schemas
│   ├── script      # Script files (sql, bash, etc.)
│   ├── util        # Resuable modules
│   └── index.js    # Application entry file
└── test            # Test files

Note: some files were omitted for simplicity.

Get started

  1. Clone the repo:
git clone https://github.com/ruanmartinelli/api-starter.git <NEW_NAME>
cd <NEW_NAME>

# make it yours:
rm -rf .git
git init
  1. Install dependencies
yarn install
  1. Create a .env file (remember to add your keys)
mv .env.example .env
  1. Run migrations:
npm run db:latest

Note: this assumes you have MySQL installed

  1. Run
npm run dev

npm Scripts

Start the server in Production mode:

npm start 

Start the server in Development mode:

npm run dev 

Show lint errors:

npm run lint

Show lint errors and fix minor issues:

npm run lint:fix

Run AVA tests:

npm t

Run AVA tests in watch mode:

npm run test:watch

Generate API documentation:

npm run docs

Conventions

License

MIT © Ruan Martinelli