-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 4745104
Showing
193 changed files
with
46,248 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
DB_CONNECT = mongodb://localhost/freelance | ||
TOKEN_SECRET = freelancer_go | ||
PORT = 8000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
DB_CONNECT = mongodb://localhost/db_name | ||
|
||
// DB_CONNECT = mongodb+srv://user:123@cluster0-1wqtw.mongodb.net/test | ||
|
||
TOKEN_SECRET = freelancer_go |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# freelancer_website | ||
|
||
-trc khi chạy thì chạy lệnh: npm install | ||
(để cài đặt package lưu trong file node_modules - nếu có rồi thì thôi) | ||
|
||
-vào file .env để cấu hình các biến môi trường | ||
(db- chỉ cần phải tạo database ở bên ngoài trc ko cần tạo model, port: tùy ý, ví dụ 8000) | ||
(link xem db online https://cloud.mongodb.com/v2/5e99784ce1b567558c1ac2c5#metrics/replicaSet/5ea69de3d2699e2ef2d02ab0/explorer/test/users/find ) | ||
-xong thì chạy: npm start | ||
|
||
-bật trình duyệt chạy: localhost:8000 (cái port này có thể đổi trong file .env) | ||
|
||
------------------------------------------------------------------------------- | ||
|
||
----models: chứa các model | ||
- | ||
- | ||
----public: chứa các folder images, stylesheets, javascripts (dùng css, js, img thì thêm file vào đây, xem ví dụ ở cái home.ejs khi muốn gọi đến cái css cần dùng,....) | ||
- | ||
- | ||
----routes: chứa các file route | ||
- | ||
- | ||
----views: chứa các file giao diện là các file .ejs (viết đc js trong html) | ||
- | ||
- | ||
---- .env: chứa file config DB_CONNECT, PORT để chạy db và server | ||
- | ||
- | ||
----... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
var createError = require('http-errors'); | ||
const express = require('express'); | ||
const app = express(); | ||
var path = require('path'); | ||
const dotenv = require('dotenv'); | ||
const mongoose = require('mongoose'); | ||
const session = require('express-session'); | ||
const bodyParser = require('body-parser') | ||
const MongoStore = require('connect-mongo')(session); | ||
var logger = require('morgan'); | ||
|
||
// Import routes | ||
const authRoute = require('./routes/auth'); | ||
const home = require('./routes/home'); | ||
const employer = require('./routes/detail-user/employer'); | ||
const candidate = require('./routes/detail-user/candidate'); | ||
|
||
dotenv.config(); | ||
|
||
// Connect to DB | ||
mongoose.connect(process.env.DB_CONNECT, | ||
{ | ||
useNewUrlParser: true, | ||
useUnifiedTopology: true | ||
}); | ||
|
||
mongoose.connection.on('error', err => { | ||
console.error('MongoDB connection error.'); | ||
console.error(err); | ||
process.exit(); | ||
}); | ||
|
||
mongoose.connection.once('open', () => { | ||
console.log(`Connected to MongoDB`); | ||
}); | ||
var db = mongoose.connection; | ||
// Set views | ||
console.log(__dirname); | ||
app.set('views', path.join(__dirname, 'views')); | ||
|
||
app.set('view engine', 'ejs'); | ||
|
||
// path | ||
app.use("/vendor",express.static("/vendor")); | ||
app.use(express.static(path.join(__dirname, 'public'))); | ||
|
||
app.use("/stylesheets",express.static(__dirname + "/stylesheets")); | ||
app.use("/javascripts",express.static(__dirname + "/javascripts")); | ||
app.use("/images",express.static(__dirname + "/images")); | ||
app.use("/vendor",express.static(__dirname + "/vendor")); | ||
// app.use("/upload",express.static(__dirname + "/upload")); | ||
app.use("/upload",express.static("upload")); | ||
|
||
// Session | ||
app.use(session({ | ||
secret: 'freePass', | ||
resave: true, | ||
saveUninitialized: false, | ||
store: new MongoStore({ | ||
mongooseConnection: db | ||
}) | ||
})); | ||
|
||
// Middleware | ||
|
||
// app.use(logger('dev')); | ||
app.use(express.json()); | ||
app.use(express.urlencoded({ extended: false })); | ||
// // for parsing application/json | ||
// app.use(bodyParser.json()); | ||
// // for parsing application/x-www-form-urlencoded | ||
// app.use(bodyParser.urlencoded({ extended: true })); | ||
|
||
// Route middleware | ||
app.use('/', home); | ||
app.use('/auth', authRoute); | ||
app.use('/employer', employer); | ||
app.use('/candidate', candidate); | ||
|
||
// catch 404 and forward to error handler | ||
app.use(function(req, res, next) { | ||
next(createError(404)); | ||
}); | ||
|
||
// error handler | ||
app.use(function(err, req, res, next) { | ||
// set locals, only providing error in development | ||
res.locals.message = err.message; | ||
res.locals.error = req.app.get('env') === 'development' ? err : {}; | ||
|
||
// render the error page | ||
res.status(err.status || 500); | ||
res.render('error'); | ||
}); | ||
|
||
const port = process.env.PORT || 5000; | ||
app.listen(port, () => console.log('Server is running on: http://localhost:' + port)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
const mongoose = require('mongoose'); | ||
const User = require('./user'); | ||
// const JobFulltime = require('./jobFulltime'); | ||
const JobFreelance = require('./jobFreelance'); | ||
|
||
const contractFreelanceSchema = new mongoose.Schema({ | ||
candidate: { | ||
type: mongoose.Schema.Types.ObjectId, | ||
required:true, | ||
ref: User | ||
}, | ||
jobFreelance: { | ||
type: mongoose.Schema.Types.ObjectId, | ||
ref: JobFreelance, | ||
required:true | ||
}, | ||
employer: { | ||
type: mongoose.Schema.Types.ObjectId, | ||
// required:true, | ||
ref: User | ||
}, | ||
message : { | ||
type: String, | ||
// required: true | ||
default: null | ||
}, | ||
confirm: { | ||
type: Number, | ||
required: true, | ||
default: 0 | ||
// 0 - chưa có gì; | ||
// 1 - nhà tuyển dụng mời ứng viên; | ||
// 2 - ứng viên quan tâm đến cv; | ||
// 3 - hợp đồng đc kí | ||
} | ||
},{ | ||
timestamps: true | ||
}); | ||
|
||
module.exports = mongoose.model('contractfreelance', contractFreelanceSchema); | ||
|
||
/** | ||
* sẽ có 2 trường hợp tạo ra model này: | ||
* 1- khi ứng viên quan tâm đến 1 công việc nào đó thì họ sẽ click vào nút : "quan tâm công việc"; | ||
* nhà tuyển dụng vào xem mà thấy ưng thì accept cho người này làm việc | ||
* khi đó việc này sẽ chuyển thành cv đang thực hiện trong trang quản lý công việc | ||
* 2- khi có nhà tuyển dụng muốn mời ứng viên tham gia các công việc đã đăng | ||
* chọn mời tam gia dự án, chuyển sang trang mời, chọn công việc muốn mời | ||
* người ứng viên đồng ý thì accept | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
const mongoose = require('mongoose'); | ||
const Schema = mongoose.Schema; | ||
const User = require('./user'); | ||
|
||
const detailCandidateSchema = new mongoose.Schema({ | ||
user: { | ||
type: mongoose.Schema.Types.ObjectId, | ||
required: true, | ||
ref: User | ||
}, | ||
sex: { | ||
type: String, | ||
required: true, | ||
default: 'khác' | ||
}, | ||
birth: { | ||
type: Date, | ||
require: true | ||
}, | ||
address: { // tỉnh thành phố thôi | ||
type: String, | ||
required: true | ||
}, | ||
experience: { // senior/junior/master | ||
type: String, | ||
required: true | ||
}, | ||
specialized: { // lĩnh vực chuyên môn: chỉ có 1 cái vd designUI | ||
type: String, | ||
required: true | ||
}, | ||
skill: [{// ví dụ như thiết kế đồ họa, web,... | ||
type: String, | ||
required: true | ||
}], | ||
description: { | ||
type: String, | ||
required: true | ||
}, | ||
freelanceInfo: { | ||
priorityWork: { // ưu tiên công việc có tgian làm bao lâu <1, 1-3, >3 | ||
type: String, | ||
require: true | ||
}, | ||
salary: { // vd 200k/h | ||
type: String, | ||
require: true | ||
} | ||
} | ||
// , | ||
// // do chủ yếu là làm về freelancer nên cái thông tin full time này k cần required true | ||
// fulltimeInfo: { | ||
// level: { // trình độ mong muốn junior-senior-master | ||
// type: String, | ||
// }, | ||
// address: { // dịa diểm muốn làm việc | ||
// type: String, | ||
// }, | ||
// salary: { // vd: 40tr/tháng | ||
// type: String, | ||
// } | ||
// } | ||
}, { | ||
timestamps: true | ||
}); | ||
|
||
module.exports = mongoose.model('detailcandidate', detailCandidateSchema); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
const mongoose = require('mongoose'); | ||
const User = require('./user'); | ||
|
||
const detailEmployerSchema = new mongoose.Schema({ | ||
user: { | ||
type: mongoose.Schema.Types.ObjectId, | ||
required:true, | ||
ref: User | ||
}, | ||
company: { | ||
name: { | ||
type: String, | ||
required: true, | ||
}, | ||
address: { | ||
type: String, | ||
required : true | ||
}, | ||
email: { | ||
type:String, | ||
require: true | ||
}, | ||
website:{ | ||
type: String, | ||
required:true | ||
}, | ||
description: { // mổ tả về lĩnh vực của công ti, quảng cáo công ti .... | ||
type: String, | ||
required: true | ||
} | ||
} | ||
},{ | ||
timestamps: true | ||
}); | ||
|
||
module.exports = mongoose.model('detailemployer', detailEmployerSchema); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
const mongoose = require('mongoose'); | ||
const User = require('./user'); | ||
const DetailEmployer = require('./detailEmployer'); | ||
const Schema = mongoose.Schema; | ||
|
||
const freelanceJobSchema = new mongoose.Schema({ | ||
name: { | ||
type: String, | ||
required: true | ||
}, | ||
field: [{ // lính vực -kinh doanh, web, thiết kế đồ họa,... | ||
type: String, | ||
required: true | ||
}], | ||
description: {//yêu cầu cviec | ||
type: String, | ||
required: true | ||
}, | ||
budget: { // ngân sách: theo giờ | ||
type: String, | ||
required: true | ||
}, | ||
timeOfWork: { | ||
type: String // việc làm theo giờ thì sẽ có tgian 3<1thang/ 1-thang/ >3thang | ||
}, | ||
levelOfCandidate: { // junior-senior-master | ||
type: String, | ||
required: true | ||
}, | ||
// salary: { | ||
// type: String, | ||
// required: true | ||
// }, | ||
creator: { // id người tạo | ||
type: Schema.Types.ObjectId, | ||
ref: User, | ||
required: true | ||
}, | ||
inActive: { | ||
type: Number, | ||
required: true, | ||
default: 1 | ||
// 1- là đang thực hiện, khi show công việc đang thực hiện, thì sẽ có nút kết thúc tuyển dụng | ||
// 0- là đã kết thúc tuyển dụng | ||
}, | ||
createAt: { | ||
type: Date, | ||
default: Date.now | ||
} | ||
},{ | ||
timestamps: true | ||
}); | ||
|
||
|
||
module.exports = mongoose.model('freelancejob', freelanceJobSchema); |
Oops, something went wrong.