This repository is used to generate a boilerplate to implement a VTEX IO service with Node.js HTTP handler.
⚠️ vtex init
is not integrated with this template yet. Meanwhile, you can download the code directly from the repository
- Install VTEX IO CLI
- Run the command
vtex init
to create an app, and follow the instructions to add a Node.js service in the app
It will create a project folder for the new app and add the Node.js service into it. Once the service is created, you can modifying it as you like.
VTEX IO runs the service as a container. A Dockerfile
to build the container image is provided by the starter, and it will be used by VTEX IO engine to build the image.
You can modify anything that is provided by default in the boilerplate, including the Dockerfile.
The generated boilerplate comes with best practices for creating VTEX IO Node.js services:
- HTTP server using Koa
- A few useful Koa middlewares are added by default. You can see them here.
- Local development and testing
- Useful yarn scripts to develop and test your service
- A sample route for REST requets
- A sample route for graphql requests
- Tests using Jest
- TypeScript setup using default VTEX configuration
- Linter using eslint with default VTEX configuration
- Automatically formats staged files before
git commit
- Code formatting using default Prettier with default VTEX configuration
Following scripts are available to be used with yarn:
yarn build
- Builds the service generating final files in thedist
folder. This will usetsc
to convert theTypeScript
files to pureJavaScript
yarn start
- Builds the service and start it onlocalhost
inprodution
� modeyarn dev
- Builds the service and start it service onlocalhost
indevelopment
� modeyarn watch
- Starts the service onlocalhost
with nodemon and ts-node, and automatically restarts the server whensrc
files are changedyarn debug
- Starts the service onlocalhost
ready for debugging the executionyarn test
- Runs tests fromsrc/__tests__
withjest
yarn lint
- Lints and formats the code
// TODO
// TODO