This is the back-end for a portfolio application. It is built using Node.js, Express, TypeScript, and MongoDB. The application supports user authentication, job examples, media collections, and contact forms.
- Installation
- Environment Variables
- Scripts
- Folder Structure
- API Endpoints
- Error Handling
- Localization
-
Clone the repository:
git clone https://github.com/yourusername/portfolio-back.git cd portfolio-back -
Install the dependencies:
npm install
-
Compile the TypeScript code:
npm run build
Create a .env file in the root directory and add the following environment variables:
PORT=3000
DEBUG=portfolio-back:*
DATABASE_URI=Your MongoDB URI
JWT_SECRET=your secret password- npm start: Start the application in production mode.
- npm run dev: Start the application in development mode with nodemon.
- npm run build: Compile the TypeScript code.
- npm run prod: Build and start the application in production mode.
- npm run initDB: Initialize the database with sample data.
- npm run thumb-req: Start the thumbnail request service.
- npm run thumb-res: Start the thumbnail response service.
- npm run dev-thumb-req: Start the thumbnail request service in development mode with nodemon.
- npm run dev-thumb-res: Start the thumbnail response service in development mode with nodemon.
.env
.env example
.gitignore
.vscode/
launch.json
env.d.ts
nodemon-requesters-responders.json
nodemon-server.json
package.json
public/
stylesheets/
style.css
readme.md
src/
app.ts
auth/
AuthController.ts
bin/
package.json
www.ts
controllers/
AudiosCollectionController.ts
BaseController.ts
ContactFormController.ts
...
initDB/
...
lib/
locales/
middlewares/
models/
register.ts
routes/
services/
types/
utils/
views/
tsconfig.json
uploads/
audio/
image/
video/- POST /api/session: Login a user.
- POST /api/users: Create a new user.
- GET /api/users: Get a list of users.
- PUT /api/users/:id: Update a user.
- DELETE /api/users/:id: Delete a user.
- POST /api/job-examples: Create a new job example.
- GET /api/job-examples: Get a list of job examples.
- GET /api/job-examples/:id: Get a specific job example.
- PUT /api/job-examples/:id: Update a job example.
- DELETE /api/job-examples/:id: Delete a job example.
- PUT /api/pictures-collection/:id: Update a pictures collection.
- PUT /api/videos-collection/:id: Update a videos collection.
- PUT /api/audios-collection/:id: Update an audios collection.
- POST /api/contact: Create a new contact form message.
- GET /api/contact: Get a list of contact form messages.
- GET /api/contact/:id: Get a specific contact form message.
- PUT /api/contact/:id: Update a contact form message.
- DELETE /api/contact/:id: Delete a contact form message.
- PUT /api/version/:id: Update (localize) a version.
The application uses a custom error handling mechanism. Errors are returned in the following format:
{
"state": "error",
"message": "Error message",
"code": 500
}The application supports multiple languages. The supported languages are defined in the src\locales\ directory. The default language is English.
To add a new language, create a new JSON file in the src\locales\ directory and add the translations.
This project is licensed under the MIT License.