Skip to content

Commit

Permalink
push to github
Browse files Browse the repository at this point in the history
  • Loading branch information
theiconik committed Aug 1, 2021
0 parents commit 1dfe009
Show file tree
Hide file tree
Showing 26 changed files with 20,003 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto
76 changes: 76 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env

# parcel-bundler cache (https://parceljs.org/)
.cache

# next.js build output
.next

# nuxt.js build output
.nuxt

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless

# FuseBox cache
.fusebox/
35 changes: 35 additions & 0 deletions backend/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
const express = require("express");
const mongoose = require("mongoose");
const dotenv = require("dotenv");
const cors = require("cors")
const pinRoute = require("./routes/pins");
const userRoute = require("./routes/users");

const app = express();
app.use(express.json());
app.use(
cors({
origin:"*",
methods:["GET","POST", "DELETE"]
})
)
dotenv.config();

mongoose
.connect(process.env.MONGO_URL, {
useNewUrlParser: true,
useUnifiedTopology: true,
})
.then(() => {
console.log("Connected to MongoDB");
})
.catch((err) => {
console.log("Error connecting to MongoDB", err);
});

app.use("/api/users", userRoute);
app.use("/api/pins", pinRoute);

app.listen(process.env.PORT || 8800, () => {
console.log("Listening on port 8800");
});
39 changes: 39 additions & 0 deletions backend/models/Pin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
const mongoose = require("mongoose");

const pinSchema = new mongoose.Schema(
{
username: {
type: String,
require: true,
},
landmark: {
type: String,
require: true,
min: 3,
},
description: {
type: String,
require: true,
min: 5,
},
contact: {
type: String,
},
price: {
type: String,
require: true,
min: 2,
},
lat: {
type: Number,
require: true,
},
long: {
type: Number,
require: true,
},
},
{ timestamps: true }
);

module.exports = mongoose.model("Pin", pinSchema);
25 changes: 25 additions & 0 deletions backend/models/User.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const mongoose = require("mongoose");

const userSchema = new mongoose.Schema({
username: {
type: String,
require: true,
min:3,
max:20,
unique: true,
},
email: {
type: String,
require: true,
unique: true,
max: 50,
},
password: {
type: String,
require: true,
min:6,
},
}, {timestamps: true}
);

module.exports = mongoose.model("User", userSchema);
Loading

0 comments on commit 1dfe009

Please sign in to comment.