Template for a express API with typescript and yup validation
MIT License
This is a template for a express API with typescript and yup validation.
npm install
or yarn
npm run dev
or yarn dev
|-- dist/
|-- src/
|-- middleware/
|-- routes/
|-- schemas/
|-- utils/
|-- types/
|-- tests/
.env
dist
: This folder contains the compiled code. may not exist if you haven't run the build script yet.src
: This folder contains the source code.src/middleware
: This folder contains the middlewares. functions that have access to the request and response objects before the request is handled by the route.src/routes
: This folder contains the routes. functions that handle the request and send the response.src/schemas
: This folder contains the schemas. functions that validate the request body.src/utils
: This folder contains the utils. functions that are used in multiple places.src/utils/types
: This folder contains the types. typescript types.src/tests
: This folder contains the tests. functions that test the code.The environment variables are stored in the .env
file.
example env file:
PORT=3000
npm run dev
or yarn dev
: Runs the development servernpm run build
or yarn build
: Builds the project for production into the dist
foldernpm run start
or yarn start
: Runs the production servernpm run test
or yarn test
: Runs the tests [!!!]!!!: The tests are not implemented in this template as they are personal/situational preference. You can use any testing framework you want
Testing is an important part of any software development project. It helps ensure that your code is working correctly and prevents bugs and errors from being introduced into your application.
Here are some recommendations:
You can also use a test framework that is not listed here.
MIT
Diego Vallejo - @DiegoVallejoDev
Feel free to contribute to this project by opening a pull request or an issue.