A simple Express API starter with some sample middleware and routes that you can deploy to AWS or Heroku. This starter also includes some basic configuration files and tests.
- Commitizen—for commit message formatting.
- commitlint—for commit message linting.
- Conventional Commits—as the specification for commit messages.
- ESLint—for linting using the Airbnb JavaScript style guide.
- Express—as the Node.js framework.
- GitHub Actions—for CI/CD.
- Jest—as the testing framework.
- lint-staged—for pre-commit code formatting and linting.
- Node.js
- Passport—as the authentication middleware.
- PM2—as the process manager for Node.js.
- Prettier—for code formatting.
- semantic-release—for automating the package release workflow.
- Serverless Express—for deploying to AWS.
- Swagger—for API documentation.
-
Clone the repo.
Clone the repo and run the
onClone.js
script.git clone https://github.com/karlpawlowicz/express-api-starter.git my-app && node my-app/scripts/onClone.js
-
Install the dependencies.
Move into the project directory and install the dependencies.
cd my-app && npm install
-
Run the server.
Run the server in development mode. The server is now running at
http://localhost:3001
and will reload if you make edits.npm start
Initial project structure:
my-app
├── .github
├── .vscode
├── logs
├── node_modules
├── scripts
├── src
│ ├── middleware
│ ├── routes
│ │ ├── auth
│ │ └── health
│ └── utils
├── tests
│ ├── integration
│ ├── mockData
│ └── unit
├── .env
├── .eslintrc.js
├── .gitignore
├── .nvmrc
├── .prettierignore
├── .prettierrc.js
├── app.json
├── commitlint.config.js
├── CONTRIBUTING.md
├── ecosystem.config.js
├── jest.config.js
├── LICENSE
├── package-lock.json
├── package.json
├── Procfile
├── README.md
└── release.config.js
-
/.github
—this directory contains GitHub-related files. -
/.vscode
—this directory contains the user and workspace settings file for VS Code. -
/logs
—this directory contains the log files. -
/node_modules
—this directory contains the project dependencies. -
/scripts
—this directory contains the script files. -
/src
—this directory contains the source code files. -
/tests
—this directory contains the tests. -
.env
—this file contains the environment variables. -
.eslintrc.js
—this file contains the configuration for ESLint. -
.gitignore
—this file tells Git which files to ignore. -
.nvmrc
—this file tells nvm which version to use. -
.prettierignore
—this file tells Prettier which files to ignore. -
.prettierrc.js
—this file contains the configuration for Prettier. -
app.json
—this file contains the manifest for this Heroku app. -
commitlint.config.js
—this file contains the configuration for commitlint. -
CONTRIBUTING.MD
—this file contains information about contributing. -
ecosystem.config.js
—this file contains the configuration for PM2. -
jest.config.js
—this file contains the configuration for Jest. -
LICENSE
—this starter uses the MIT License. -
package-lock.json
—this file is generated automatically by npm and contains the exact versions of the installed project dependencies. -
package.json
—this file contains the manifest for this Node.js project. -
Procfile
—this file contains the commands that are executed by the app on startup on Heroku. -
README.md
—this file contains information about this project. -
release.config.js
—this file contains the configuration for semantic-release.
In the project directory, you can run:
npm run format
Runs Prettier on css
, js
, json
, jsx
, md
, scss
, ts
, and tsx
file extensions.
npm run lint
Runs ESLint using the Airbnb JavaScript style guide. You will see any lint errors in the console.
npm run lint:fix
Runs ESLint and automatically fixes problems using the Airbnb JavaScript style guide. You will see any lint errors in the console.
npm run logs
Runs the server logs. You will see any server errors in the console.
npm run serve
Runs the server in production mode.
npm run serve:heroku
Runs the server without PM2.
npm start
Runs the server in development mode. The server is now running at http://localhost:3001
and will reload if you make edits.
npm stop
Stops the server.
npm test
Runs Jest. You will see the test results in the console.
npm run test:watch
Runs Jest in watch mode. You will see the test results in the console. Jest will rerun the tests if you make edits.
You can deploy this app to Heroku with the included Procfile
, which will run the serve:heroku
command after the dependencies finish installing.
See CONTRIBUTING.MD.
Licensed under the MIT License.