This is a Node.js backend application for managing jobs. It uses Sequelize as an ORM and MySQL as the database. The project supports TypeScript for scalability and maintainability.
Make sure you have the following installed:
- Node.js (v14+ recommended)
- npm (comes with Node.js)
- MySQL database (can be an AWS RDS instance or another MySQL-compatible provider like Aiven) - hERE I HAVE AIVEN 🦀🦀
git clone https://github.com/AryamanSi17/jobBackendAssignment.git
cd jobBackendAssignmentnpm installCreate a .env file in the root of the project and add the following variables:
DB_HOST=<your-database-host>
DB_PORT=21577
DB_NAME=<your-database-name>
DB_USER=<your-database-username>
DB_PASSWORD=<your-database-password>
DB_SSL_MODE=REQUIREDCompile the TypeScript code to JavaScript:
npm run buildStart the server:
npm startThe server will run on http://localhost:3000 by default.
You can test the API using Postman or a similar tool.
-
Create a Job:
POST /api/jobs- Body:
{ "title": "Software Engineer", "company": "Example Corp", "location": "Remote", "salary": 120000, "description": "Develop and maintain web applications." }
-
Get All Jobs:
GET /api/jobs
-
Get Job by ID:
GET /api/jobs/:id
-
Update a Job:
PUT /api/jobs/:id- Body (partial or full):
{ "location": "Onsite" }
-
Delete a Job:
DELETE /api/jobs/:id
jobBackendAssignment
├── src
│ ├── config
│ │ └── db.ts # Database connection setup
│ ├── controllers
│ │ └── jobController.ts # Controller for job-related operations
│ ├── middlewares
│ │ └── errorHandler.ts # Custom error handling middleware
│ ├── models
│ │ └── jobModel.ts # Job model definition
│ ├── routes
│ │ └── jobRoutes.ts # Routes for job endpoints
│ ├── app.ts # Express app setup
│ └── server.ts # Server entry point
├── dist # Compiled JavaScript output
├── .env # Environment variables
├── package.json # Project dependencies and scripts
└── tsconfig.json # TypeScript configuration
-
connect ETIMEDOUTorECONNREFUSED:- Ensure your database is publicly accessible or that the necessary security groups and firewalls allow connections from your IP.
-
Unknown database:- Make sure the database exists and matches the
DB_NAMEin your.envfile.
- Make sure the database exists and matches the
Feel free to submit issues or pull requests to improve the project.