Example Node (Express + Knex) codebase containing real world examples (CRUD, auth, advanced patterns, etc) that adheres to the RealWorld API spec.
This repository has been approved and included on the project page by the Codebase.show team. I am committed to continuously improving this codebase and incorporating new technologies and useful Node modules as I discover them.
I created a separate repository to deploy this project architecture via Aws Cdk. Please check this repository.
This repository has complete functionality — pull requests and issues are welcome!
Demo | Get Started | Architecture | Contributing
To demonstrate the functionality of the backend, we have deployed a live demo version of the application. You can visit the demo by following this link: https://conduit-api-prod.kenyip.cc.
The API has several endpoints that you can test out using a tool like Postman or cURL. You can find the documentation for the API endpoints on the API documentation page. Feel free to use this endpoint to create your amazing frontend applications!
Please note that the demo version of the application is intended for demonstration purposes only and may not be suitable for production use. If you would like to deploy the application yourself, please follow the instructions in the Get Started section of this README.
This project utilizes Yarn as its package manager. Please ensure that Yarn is installed before you begin working on this project.
To start the Docker setup, run the following commands:
docker-compose build
docker-compose up -d
The Docker Compose configuration includes the API server, MySQL database, and the necessary program to set up the required tables for the application to function correctly.
- Configure the environment variables according to the table below:
Env | Description | Required |
---|---|---|
NODE_ENV | Environment in which the application is running (e.g., develop, test, ci, production) | Yes |
DOMAIN | Domain name for the application | No |
AUTH_EXPIRES_IN | Duration for which the authentication token is valid | No |
AUTH_JWT_SECRET | Secret key used for signing JWT tokens | Yes |
DATABASE_HOST | Hostname of the database server | Yes |
DATABASE_PORT | Port number on which the database is listening | Yes |
DATABASE_USER | Username for database authentication | Yes |
DATABASE_PASSWORD | Password for database authentication | Yes |
DATABASE_NAME | Name of the database to connect to | Yes |
-
Execute the following commands to install all dependencies and launch the development server:
yarn yarn dev
-
Afterward, navigate to http://localhost:3100/api/health-check to verify if the server is operating correctly.
This project utilizes the Express Serverless framework along with Amazon CDK to deploy the server in a serverless architecture. You can find the ./infra folder in the root directory, which contains all the setup code related to this server. To view the entire architecture, including roles, buckets, and the CodeBuild pipeline, please refer to this repository.
To deploy the application, run yarn deploy --all
in the command line interface. If you need more detailed explanations on the techniques and application architecture, refer to the architecture section.
For more information on deploying a serverless application with Amazon SAM, please visit the AWS documentation.
I have written a blog post about the techniques, structure, architecture, and my reflections on this project. For more details, click here!
Please review the existing issues in this repository for areas that require improvement. If you identify any missing or potential areas for improvement, feel free to open a new issue for them.
Before deploying and integrating the application, it is necessary to perform a series of validations such as testing, linting, and formatting. We recommend running make pre-commit
before making each commit to ensure compliance.
This project is licensed under the MIT License - see the MIT file for details.