Code Monkey home page Code Monkey logo

express-yup-typescript-template's Introduction

Express Yup Typescript template

This is a template for a express API with typescript and yup validation.

Getting started

  1. Clone the repository
  2. install dependencies with npm install or yarn
  3. Create a .env file and set the environment variables (e.g., PORT, DATABASE_URL, etc.).
  4. Run the development server using npm run dev or yarn dev

Project structure

   |-- 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.

Environment variables

The environment variables are stored in the .env file. example env file:

PORT=3000

Scripts

  • npm run dev or yarn dev: Runs the development server
  • npm run build or yarn build: Builds the project for production into the dist folder
  • npm run start or yarn start: Runs the production server
  • npm 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.

License

MIT

Author

Diego Vallejo - @DiegoVallejoDev

Contributing

Feel free to contribute to this project by opening a pull request or an issue.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.