Skip to content
Snippets Groups Projects
Commit 789ceebe authored by Fin Wallis's avatar Fin Wallis
Browse files

Merge branch 'master' into 'main'

Master

See merge request !1
parents 3088155e c966dcca
No related branches found
No related tags found
1 merge request!1Master
Showing
with 198 additions and 0 deletions
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
/Backend/node_modules
/frontend/node_modules
/.pnp
.pnp.js
# testing
/coverage
# production
/build
# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
npm-debug.log*
yarn-debug.log*
yarn-error.log*
{
"presets": [
"env",
"stage-0"
]
}
\ No newline at end of file
const {check, validationResult } = require('express-validator');
exports.signupValidator = [
check('firstName').not().isEmpty().trim().withMessage("First name is required"),
check('lastName').not().isEmpty().trim().withMessage("Last name is required"),
check('email').isEmail().normalizeEmail().withMessage("Last name is required"),
check('password').isLength({min: 6}).withMessage("Password msut be at least 6 characters long"),
]
// module.exports = signupValidator
exports.validatorResult = (req, res, next) => {
const result = validationResult(req);
const hasErrors = !result.isEmpty();
if (hasErrors) {
console.log('Has errors:', hasErrors)
console.log("result", result)
}
next();
}
// module.exports = validationResult
\ No newline at end of file
// export vs module exports (which works) - fix refactor later
export const test = (req, res) => {
// res.send(req.body)
console.log("inside controller")
};
module.exports = test
\ No newline at end of file
import mongoose from 'mongoose';
import { EventSchema } from '../models/eventModel';
// Creating event object
const Event = mongoose.model('Event', EventSchema);
export const addNewEvent = (req, res) => {
let newEvent = new Event(req.body);
newEvent.save((err, Event) => {
if (err) {
res.send(err);
}
res.json(Event)
});
};
export const getEvents = (req, res) => {
Event.find({}, (err, Event) => {
if (err) {
res.send(err);
}
res.json(Event)
});
};
import express from 'express';
import mongoose from 'mongoose';
import cors from 'cors';
import eventRoutes from './routes/eventRoutes';
import authRoutes from './routes/authRoutes';
// Creating express object and declaring hosting server port
const app = express();
const PORT = 4000;
// MongoDB connection
mongoose.Promise = global.Promise;
mongoose.connect('mongodb://localhost/TickcryptDB', {
useNewUrlParser: true,
useUnifiedTopology: true
})
.then((result) => console.log('Connected to DB'))
.catch((err) => console.log(err));
// Body parser setup
app.use(express.urlencoded({extended: true}));
app.use(express.json());
// CORS setup
app.use(cors());
// Declaring routes to the express server
eventRoutes(app)
authRoutes(app)
app.get('/', (req, res) =>
res.send(`Tickcrypt app is running on ${PORT}`)
);
app.listen(PORT, () =>
console.log(`Your app server is running on port ${PORT}`)
);
import mongoose from 'mongoose';
const Schema = mongoose.Schema
export const EventSchema = new Schema({
eventTitle: {
type: String,
required: true,
trim: true
},
organiser: {
type: String,
required: true,
trim: true
},
venueName: {
type: String,
required: true,
trim: true
},
venueAddress: {
type: String,
required: true,
trim: true
},
eventType: {
type: String,
required: true
},
startDate: {
type: String,
required: true
},
endDate: {
type: String,
required: true
},
startTime: {
type: String,
required: true
},
endTime: {
type: String,
required: true
},
eventImage: {
type: String,
// required: true
},
eventDescription: {
type: String,
required: true
},
createdDate: {
type: Date,
default: Date.now
}
})
\ No newline at end of file
../atob/bin/atob.js
\ No newline at end of file
../babel-cli/bin/babel.js
\ No newline at end of file
../babel-cli/bin/babel-doctor.js
\ No newline at end of file
../babel-cli/bin/babel-external-helpers.js
\ No newline at end of file
../babel-cli/bin/babel-node.js
\ No newline at end of file
../babylon/bin/babylon.js
\ No newline at end of file
../is-ci/bin.js
\ No newline at end of file
../loose-envify/cli.js
\ No newline at end of file
../mime/cli.js
\ No newline at end of file
../mkdirp/bin/cmd.js
\ No newline at end of file
../nodemon/bin/nodemon.js
\ No newline at end of file
../touch/bin/nodetouch.js
\ No newline at end of file
../nopt/bin/nopt.js
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment