Remove backfiles for splitting
This commit is contained in:
parent
4ce2382964
commit
c08e860dfe
6 changed files with 0 additions and 1250 deletions
|
|
@ -1,20 +0,0 @@
|
|||
# Use the official Node.js 22 image
|
||||
FROM node:22
|
||||
|
||||
# Create and change to the app directory
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
# Copy application dependency manifests to the container image
|
||||
COPY package*.json ./
|
||||
|
||||
# Install dependencies
|
||||
RUN npm install
|
||||
|
||||
# Copy application code
|
||||
COPY . .
|
||||
|
||||
# Expose the port the app runs on
|
||||
EXPOSE 5000
|
||||
|
||||
# Run the application
|
||||
CMD [ "node", "server.js" ]
|
||||
|
|
@ -1,57 +0,0 @@
|
|||
const mongoose = require('mongoose');
|
||||
const bcrypt = require('bcryptjs');
|
||||
|
||||
const userSchema = new mongoose.Schema({
|
||||
username: { type: String, required: true, unique: true },
|
||||
password: { type: String, required: true },
|
||||
});
|
||||
|
||||
userSchema.pre('save', async function(next) {
|
||||
if (this.isModified('password')) {
|
||||
this.password = await bcrypt.hash(this.password, 10);
|
||||
}
|
||||
next();
|
||||
});
|
||||
|
||||
userSchema.methods.comparePassword = function(candidatePassword) {
|
||||
return bcrypt.compare(candidatePassword, this.password);
|
||||
};
|
||||
|
||||
const User = mongoose.model('User', userSchema);
|
||||
|
||||
const projectSchema = new mongoose.Schema({
|
||||
title: String,
|
||||
description: String,
|
||||
images: [String],
|
||||
});
|
||||
|
||||
const educationSchema = new mongoose.Schema({
|
||||
degree: String,
|
||||
institution: String,
|
||||
startYear: Number,
|
||||
endYear: Number,
|
||||
});
|
||||
|
||||
const jobExperienceSchema = new mongoose.Schema({
|
||||
jobTitle: String,
|
||||
company: String,
|
||||
startYear: Number,
|
||||
endYear: Number,
|
||||
});
|
||||
|
||||
const resumeSchema = new mongoose.Schema({
|
||||
pdfURL: String,
|
||||
});
|
||||
|
||||
const socialSchema = new mongoose.Schema({
|
||||
platform: String,
|
||||
url: String,
|
||||
});
|
||||
|
||||
const Project = mongoose.model('Project', projectSchema);
|
||||
const Education = mongoose.model('Education', educationSchema);
|
||||
const JobExperience = mongoose.model('JobExperience', jobExperienceSchema);
|
||||
const Resume = mongoose.model('Resume', resumeSchema);
|
||||
const Social = mongoose.model('Social', socialSchema);
|
||||
|
||||
module.exports = { User, Project, Education, JobExperience, Resume, Social };
|
||||
1057
backend/package-lock.json
generated
1057
backend/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -1,21 +0,0 @@
|
|||
{
|
||||
"name": "backend",
|
||||
"version": "1.0.0",
|
||||
"main": "server.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"description": "",
|
||||
"dependencies": {
|
||||
"bcryptjs": "^2.4.3",
|
||||
"body-parser": "^1.20.2",
|
||||
"cors": "^2.8.5",
|
||||
"dotenv": "^16.4.5",
|
||||
"express": "^4.19.2",
|
||||
"jsonwebtoken": "^9.0.2",
|
||||
"mongoose": "^8.5.0"
|
||||
}
|
||||
}
|
||||
|
|
@ -1,78 +0,0 @@
|
|||
const express = require('express');
|
||||
const jwt = require('jsonwebtoken');
|
||||
const bcrypt = require('bcryptjs');
|
||||
const { User, Project, Education, JobExperience, Resume, Social } = require('./models');
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
const JWT_SECRET = process.env.JWT_SECRET;
|
||||
|
||||
// Register route
|
||||
router.post('/register', async (req, res) => {
|
||||
const { username, password } = req.body;
|
||||
const user = new User({ username, password });
|
||||
await user.save();
|
||||
res.send({ message: 'User registered successfully' });
|
||||
});
|
||||
|
||||
// Login route
|
||||
router.post('/login', async (req, res) => {
|
||||
const { username, password } = req.body;
|
||||
const user = await User.findOne({ username });
|
||||
if (!user || !(await user.comparePassword(password))) {
|
||||
return res.status(401).send({ error: 'Invalid username or password' });
|
||||
}
|
||||
const token = jwt.sign({ userId: user._id }, JWT_SECRET, { expiresIn: '1h' });
|
||||
res.send({ token });
|
||||
});
|
||||
|
||||
// Middleware to authenticate and authorize
|
||||
const authenticate = (req, res, next) => {
|
||||
const token = req.headers.authorization?.split(' ')[1];
|
||||
if (!token) {
|
||||
return res.status(401).send({ error: 'Unauthorized' });
|
||||
}
|
||||
try {
|
||||
const payload = jwt.verify(token, JWT_SECRET);
|
||||
req.user = payload;
|
||||
next();
|
||||
} catch (err) {
|
||||
return res.status(401).send({ error: 'Unauthorized' });
|
||||
}
|
||||
};
|
||||
|
||||
// Protect admin routes
|
||||
router.use('/admin', authenticate);
|
||||
|
||||
// Admin routes
|
||||
router.post('/admin/projects', async (req, res) => {
|
||||
const project = new Project(req.body);
|
||||
await project.save();
|
||||
res.send(project);
|
||||
});
|
||||
|
||||
router.post('/admin/education', async (req, res) => {
|
||||
const education = new Education(req.body);
|
||||
await education.save();
|
||||
res.send(education);
|
||||
});
|
||||
|
||||
router.post('/admin/job-experience', async (req, res) => {
|
||||
const jobExperience = new JobExperience(req.body);
|
||||
await jobExperience.save();
|
||||
res.send(jobExperience);
|
||||
});
|
||||
|
||||
router.post('/admin/resume', async (req, res) => {
|
||||
const resume = new Resume(req.body);
|
||||
await resume.save();
|
||||
res.send(resume);
|
||||
});
|
||||
|
||||
router.post('/admin/socials', async (req, res) => {
|
||||
const social = new Social(req.body);
|
||||
await social.save();
|
||||
res.send(social);
|
||||
});
|
||||
|
||||
module.exports = router;
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
const express = require('express');
|
||||
const mongoose = require('mongoose');
|
||||
const bodyParser = require('body-parser');
|
||||
const cors = require('cors');
|
||||
const routes = require('./routes');
|
||||
require('dotenv').config();
|
||||
|
||||
const app = express();
|
||||
app.use(cors());
|
||||
app.use(bodyParser.json());
|
||||
|
||||
mongoose.connect(process.env.MONGO_URI, { useNewUrlParser: true, useUnifiedTopology: true });
|
||||
|
||||
app.use('/api', routes);
|
||||
|
||||
const PORT = process.env.PORT || 5000;
|
||||
app.listen(PORT, () => console.log(`Server running on port ${PORT}`));
|
||||
Loading…
Add table
Add a link
Reference in a new issue