commit
This commit is contained in:
@@ -0,0 +1,31 @@
|
|||||||
|
const {JWTManager} = require("auth-guardian");
|
||||||
|
const dotenv = require("dotenv");
|
||||||
|
|
||||||
|
dotenv.config();
|
||||||
|
|
||||||
|
const jwtAuth = new JWTManager.jwtAuth(process.env.JWT_SECRET);
|
||||||
|
|
||||||
|
function generateAccesToken(user){
|
||||||
|
return jwtAuth.generateJWT({user: user}, {expiresIn: "1h"});
|
||||||
|
}
|
||||||
|
|
||||||
|
function generateRefreshToken(user){
|
||||||
|
return jwtAuth.generateJWT({user: user}, {expiresIn: "7d"});
|
||||||
|
}
|
||||||
|
|
||||||
|
function generatePermtoken(user){
|
||||||
|
return jwtAuth.generateJWT({user: user}, {expiresIn: "60d"});
|
||||||
|
}
|
||||||
|
|
||||||
|
function verifyToken(token){
|
||||||
|
return jwtAuth.verifyJWT(token);
|
||||||
|
}
|
||||||
|
|
||||||
|
function verifyRefreshToken(token){
|
||||||
|
return jwtAuth.verifyJWT(token);
|
||||||
|
}
|
||||||
|
|
||||||
|
function verifyPermtoken(token){
|
||||||
|
return jwtAuth.verifyJWT(token);
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
const express = require('express');
|
||||||
|
const dotenv = require('dotenv');
|
||||||
|
const cors = require('cors');
|
||||||
|
const auth = require('./auth.js');
|
||||||
Generated
+1906
File diff suppressed because it is too large
Load Diff
+15
-1
@@ -7,5 +7,19 @@
|
|||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
},
|
},
|
||||||
"author": "kaj van schalkwijk",
|
"author": "kaj van schalkwijk",
|
||||||
"license": "MIT"
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"auth-guardian": "^1.0.2",
|
||||||
|
"bcrypt": "^5.1.1",
|
||||||
|
"cookie-parser": "^1.4.6",
|
||||||
|
"cors": "^2.8.5",
|
||||||
|
"dotenv": "^16.3.1",
|
||||||
|
"express": "^4.18.2",
|
||||||
|
"jsonwebtoken": "^9.0.2",
|
||||||
|
"surrealdb.node": "^0.3.0",
|
||||||
|
"timestringconverter": "^1.0.0"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"nodemon": "^3.0.2"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+28
@@ -0,0 +1,28 @@
|
|||||||
|
const { Surreal } = require('surrealdb.node');
|
||||||
|
|
||||||
|
const db = new Surreal();
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Connect to the database
|
||||||
|
await db.connect('wss://db.services.quiztimes.nl/rpc');
|
||||||
|
|
||||||
|
// Signin as a namespace, database, or root user
|
||||||
|
await db.signin({
|
||||||
|
username: 'root',
|
||||||
|
password: 'root',
|
||||||
|
});
|
||||||
|
|
||||||
|
// Select a specific namespace / database
|
||||||
|
await db.use({ ns: 'forum', db: 'forum' });
|
||||||
|
|
||||||
|
} catch (e) {
|
||||||
|
console.error('ERROR', e);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
main();
|
||||||
|
|
||||||
|
module.exports = db;
|
||||||
Reference in New Issue
Block a user