Opinionated Node.js template for creating simple APIs and PoCs using Express1 on Vercel's serverless platform.
Simply put, I got tired of having to do the same dance EVERY SINGLE TIME I needed to quickly spin up an API for a POC I'm working on, or small (micro? 😁) services I spin up.
Making use of this template is pretty straightforward. Three ways...
- Clone it,
- Fork it, or,
- Even better, generate a new project on Github using this as a template.
.
├── app.js
├── config/
├── controllers/
├── node_modules/
├── package.json
├── routes/
│ ├── demo.route.js
│ └── index.js
├── services/
├── common/
├── vercel.json
└── yarn.lock
Express app entry point
for configuration stuff... for example, database connection setup
mostly express route handlers
black hole 🙃
index.js
– bootstraps all routes. new namespaces should always be registered heredemo.route.js
– sample standalone route
for "external" services (e.g. a weather.service.js file for interacting with darksky API)
¯\_(ツ)_/¯
After cloning/forking this template, the following endpoints can be immediately accessed:
GET /
GET /demo
1 depending on your use-case, making use of Express with Vercel's serverless platform may not be ideal as they suggest making use of the helpers provided for handling requests and making use of the Vercel config file for routing.
While I do make use of the helpers and routing for some projects (sample), I also love using Express as it drastically reduces routing complexity, I've not had any issues with setup, AND, it makes whatever project developed platform agnostic.