Skip to content

Commit

Permalink
project itp
Browse files Browse the repository at this point in the history
  • Loading branch information
it21222672 committed Jun 15, 2023
1 parent 635ada0 commit 18b75ff
Show file tree
Hide file tree
Showing 7 changed files with 1,693 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
1 change: 1 addition & 0 deletions backend/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ATLAS_URI= "mongodb+srv://user:[email protected]/?retryWrites=true&w=majority"
29 changes: 29 additions & 0 deletions backend/app.js
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}`);
});
46 changes: 46 additions & 0 deletions backend/models/payment.js
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;
Loading

0 comments on commit 18b75ff

Please sign in to comment.