Skip to content

Commit

Permalink
added function to upload image
Browse files Browse the repository at this point in the history
  • Loading branch information
anndimi committed Jan 19, 2022
1 parent 8f1200a commit ef9518e
Show file tree
Hide file tree
Showing 13 changed files with 17,561 additions and 211 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ build
.env.development.local
.env.test.local
.env.production.local

.env
npm-debug.log*
yarn-debug.log*
yarn-error.log*
55 changes: 55 additions & 0 deletions backend/Schemas/add.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import mongoose from "mongoose";

export const AddSchema = new mongoose.Schema({
title: {
type: String,
},
description: {
type: String,
minlength: 30,
maxlength: 400,
trim: true,
},
budget: {
type: Number,
},
currency: {
type: String,
enum: ["SEK", "EUR", "USD", "NOK", "GBP", "DKK", "CNY"],
},
category: {
type: String,
enum: [
"Frontend",
"Backend",
"Graphics and Design",
"Fullstack",
"App Developer",
"Chatbots",
"Project Lead",
"QA",
"Legal Consulting",
"Financial Consulting",
"Analytics",
"Game Developer",
],
},
time: {
type: Date,
},
createdAt: {
type: Number,
default: () => Date.now(),
},
typeOf: {
type: String,
enum: ["Looking for", "Join"],
},
user: {
type: mongoose.Schema.Types.ObjectId,
ref: "User",
},
});

const Add = mongoose.model("Add", AddSchema);
module.exports = Add;
52 changes: 0 additions & 52 deletions backend/Schemas/add.js

This file was deleted.

69 changes: 69 additions & 0 deletions backend/Schemas/user.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import mongoose from "mongoose";
import crypto from "crypto";

//to validate the email when signing up/in
const validateEmail = (email) => {
const re = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
return re.test(email);
};

export const UserSchema = new mongoose.Schema({
username: {
type: String,
unique: true,
required: true,
},
email: {
type: String,
trim: true,
lowercase: true,
unique: true,
required: "Email address is required",
validate: [validateEmail, "Please fill a valid email address"],
match: [
/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/,
"Please fill a valid email address",
],
},
password: {
type: String,
required: true,
},
accessToken: {
type: String,
default: () => crypto.randomBytes(128).toString("hex"),
},
location: {
type: String,
},
name: {
type: String,
trim: true,
minlength: 2,
},
memberSince: {
// type: Date,
// default: () => new Date(),
type: Number,
default: () => Date.now(),
},
bio: {
type: String,
trim: true,
minlength: 10,
maxlength: 250,
},
linkedIn: {
type: String,
},
github: {
type: String,
},
userImage: {
type: mongoose.Schema.Types.ObjectId,
ref: "UserImage",
},
});

const User = mongoose.model("User", UserSchema);
module.exports = User;
69 changes: 0 additions & 69 deletions backend/Schemas/user.js

This file was deleted.

Loading

0 comments on commit ef9518e

Please sign in to comment.