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
import {connect} from 'mongoose' | |
import {messages} from './messages' | |
connect( | |
// Do not commit prod credentials to git tho | |
'mongodb+srv://NToss:aKmgd43Sf1@cluster0.bkca8.mongodb.net/myFirstDatabase?retryWrites=true&w=majority' | |
) | |
.then(() => console.log('Successfully connected to the database')) | |
.catch(err => console.log('Could not connect to the database. Error...', err)) |
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
const mongoose = require("mongoose"); | |
const AppSchema = mongoose.Schema({ | |
message: String, | |
}); | |
module.exports = mongoose.model("App", AppSchema); |
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
import {Router} from 'express' | |
import {model, Schema} from 'mongoose' | |
const Message = model( | |
'Message', | |
new Schema({ | |
message: {type: String, required: true}, | |
}), | |
) |
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
const App = require("../model/app.model.js"); | |
// Create and Save a new Message | |
exports.create = (req, res) => { | |
const message = new App({ | |
message: req.body.message, | |
}); | |
message | |
.save() | |
.then((data) => { |
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
module.exports = (app) => { | |
const App = require("../controllers/app.controller.js"); | |
app.post("/create", App.create); | |
app.get("/get-all", App.findAll); | |
app.get("/message/:messageId", App.findOne); | |
app.put("/message/:messageId", App.update); |
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
const app = express(); | |
app.use(bodyParser.urlencoded({extended: true})); | |
app.use(bodyParser.json()); | |
app.get("/", (req, res) => { | |
res.json({message: "Server is running :D"}); | |
}); | |
require("./app/routes/app.routes.js")(app); |
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
const {Pool} = require('pg') | |
const app = express() | |
const pool = new Pool({ | |
// confing | |
}) | |
app.get('/submissions', requiresAuth(), async (req, res) => { | |
const {rows} = await pool.query( | |
` | |
SELECT * |
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
const testQuery = async query => { | |
const pool = new sql.ConnectionPool({ // ... //}) | |
try { | |
await pool.connect() | |
return await pool.request().query(` | |
BEGIN TRANSACTION | |
${query} | |
ROLLBACK TRANSACTION | |
`) |
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
const {Pool} = require('pg') | |
const express = require('express') | |
const {auth, requiresAuth} = require('express-openid-connect') | |
const app = express() | |
// Enable OIDC support | |
// To login into the app use cirnotoss@gmail.com/Lol2021 | |
app.use( | |
auth({ |
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
SELECT * | |
FROM ( | |
SELECT IT.ID, | |
ROW_NUMBER() | |
OVER ( | |
PARTITION BY | |
IT.VendorId, | |
IT.ItemNumber, | |
I.StoreID | |
ORDER BY I.InvoiceDate DESC, IT.InvoiceID DESC |
NewerOlder