Welcome to the Car-ify project! This repository contains a Node.js application that serves a Car API. The API allows users to fetch details of cars using both RESTful endpoints and GraphQL queries. The API documentation is generated using Swagger, and the application is built using the Fastify framework for its speed, security, and plugin architecture. MongoDB is used as the database, and Mongoose provides a schema-based solution for modeling application data.
- Fastify: Fastify is a web framework highly focused on providing the best developer experience with the least overhead and a powerful plugin architecture.
- Mongoose: Mongoose provides a straightforward, schema-based solution to model application data. It includes built-in type casting, validation, query building, business logic hooks, and more.
- Swagger: Swagger documentation generator for Fastify. It uses the schemas declared in routes to generate a Swagger-compliant documentation.
- GraphQL: GraphQL is a query language for APIs and a runtime for executing those queries by using a type system defined by the user.
- fastify-swagger: Plugin for Fastify to generate Swagger documentation automatically.
- boom: Utility library for returning HTTP errors.
To get started with Car-ify, follow these steps:
-
Clone the repository:
git clone https://github.com/theFutureGuy/Car-ify.git
-
Install dependencies:
cd Car-ify npm install -
Set up environment variables:
Create a
.envfile in the root of the project and specify the following environment variables:MONGODB_URI=<your-mongodb-uri> PORT=<port-number>Replace
<your-mongodb-uri>with the connection URI for your MongoDB database, and<port-number>with the port number you want the server to listen on. -
Start the server:
npm start
The server will start running on the specified port, and you can access the API documentation by visiting
http://localhost:<port>/documentation.
GET /cars: Get a list of all cars.GET /cars/:id: Get details of a specific car by ID.POST /cars: Add a new car.PUT /cars/:id: Update details of a specific car by ID.DELETE /cars/:id: Delete a car by ID.
POST /graphql: Send GraphQL queries to retrieve data.
The API documentation is automatically generated using Swagger. You can access it by visiting http://localhost:<port>/documentation when the server is running.
Contributions are welcome! Feel free to open issues or submit pull requests to improve the application.
This project is licensed under the LGPL-2.1 license - see the LICENSE file for details.