This repository is used to generate a boilerplate to implement a VTEX IO service with Node.js HTTP handler.
⚠️ vtex initis not integrated with this template yet. Meanwhile, you can download the code directly from the repository
- Install VTEX IO CLI
- Run the command
vtex initto 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 thedistfolder. This will usetscto convert theTypeScriptfiles to pureJavaScriptyarn start- Builds the service and start it onlocalhostinprodution� modeyarn dev- Builds the service and start it service onlocalhostindevelopment� modeyarn watch- Starts the service onlocalhostwith nodemon and ts-node, and automatically restarts the server whensrcfiles are changedyarn debug- Starts the service onlocalhostready for debugging the executionyarn test- Runs tests fromsrc/__tests__withjestyarn lint- Lints and formats the code
// TODO
// TODO