-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
635ada0
commit 18b75ff
Showing
7 changed files
with
1,693 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 @@ | ||
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 @@ | ||
ATLAS_URI= "mongodb+srv://user:[email protected]/?retryWrites=true&w=majority" |
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,29 @@ | ||
const express = require('express'); | ||
const cors = require('cors'); | ||
const mongoose = require('mongoose'); | ||
|
||
require('dotenv').config(); | ||
|
||
const app = express(); | ||
const port = process.env.PORT || 5000; | ||
|
||
app.use(cors()); | ||
app.use(express.json()); | ||
|
||
const url = process.env.ATLAS_URI; | ||
global.URL = url; | ||
|
||
mongoose.connect(url, { useNewUrlParser: true, useCreateIndex: true, useUnifiedTopology: true }); | ||
|
||
const connection = mongoose.connection; | ||
|
||
connection.once('open', () => { | ||
console.log("MongoDB connection successfully"); | ||
}); | ||
|
||
const payment = require('./routes/payment.js'); | ||
app.use('/payment', payment); | ||
|
||
app.listen(port, () => { | ||
console.log(`Server is running on port: ${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,46 @@ | ||
const mongoose = require("mongoose"); | ||
const Schema = mongoose.Schema; | ||
const payment = new Schema( | ||
{ | ||
code: { | ||
type: String, | ||
required: true, | ||
unique: true | ||
}, stdNo: { | ||
type: String, | ||
required: true | ||
}, | ||
subject: { | ||
type: String, | ||
required: true, | ||
}, | ||
classType: { | ||
type: String, | ||
required: true, | ||
}, | ||
email: { | ||
type: String, | ||
required: true, | ||
}, | ||
date: { | ||
type: String, | ||
required: true, | ||
}, | ||
picture: { | ||
type: String, | ||
required: true, | ||
}, | ||
realPrice: { | ||
type: Number, | ||
required: true, | ||
} | ||
}, | ||
{ | ||
timestamps: true, | ||
} | ||
); | ||
const payment_Schema = mongoose.model( | ||
"payment", | ||
payment | ||
); | ||
module.exports = payment_Schema; |
Oops, something went wrong.