refactor: Deprecate /api/class/:id/topTen

This commit is contained in:
Alexander Polynomdivision 2018-10-21 16:30:41 +02:00
parent f1a1c2531c
commit 72c843aacb
3 changed files with 1 additions and 76 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "lateinicusserver", "name": "lateinicusserver",
"version": "1.4.0", "version": "1.5.0",
"description": "The backend server for Lateinicus", "description": "The backend server for Lateinicus",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {

View File

@ -1,43 +0,0 @@
import { Router, Request, Response } from "express";
import * as bodyparser from "body-parser";
import { authRoute } from "../security/token";
const classRouter = Router();
classRouter.use(bodyparser.json());
classRouter.use(authRoute);
classRouter.get("/:id/topTen", async (req: Request, res: Response) => {
// TODO: Deprecate this?
if (!req.params) {
res.send({
error: "400",
data: {
msg: "No class specified",
},
});
return;
}
console.log("STUB(get): /class/:id/topTen");
let users: any[] = [];
let nr = 10;
for (let i = 0; i < 10; i++)
users = users.concat({
username: `Test User ${i}`,
score: 100 * i,
level: Math.floor(Math.random() * Math.floor(10)),
nr: nr--,
});
// TODO: Implement
res.send({
error: "0",
data: {
topTen: users,
}
});
});
export default classRouter;

View File

@ -1,5 +1,4 @@
import { env, exit } from "process"; import { env, exit } from "process";
// import * as fs from "fs";
import { randomBytes, pbkdf2Sync } from "crypto"; import { randomBytes, pbkdf2Sync } from "crypto";
import * as assert from "assert"; import * as assert from "assert";
@ -8,9 +7,6 @@ import * as cors from "cors";
import * as bodyparser from "body-parser"; import * as bodyparser from "body-parser";
//@ts-ignore
import * as profanity from "profanity-util";
import { isAuthenticated, performLogin } from "./security/auth"; import { isAuthenticated, performLogin } from "./security/auth";
import { LRequest } from "./types/express"; import { LRequest } from "./types/express";
@ -30,12 +26,6 @@ const user = encodeURIComponent("backend");
const password = encodeURIComponent(env["LATEINICUS_USER_PW"]); const password = encodeURIComponent(env["LATEINICUS_USER_PW"]);
(async function() { (async function() {
// Load the profanity list
// const list = JSON.parse(fs.readFileSync("/etc/profanity", { encoding: "utf-8" }));
// const profanityFilter = new Filter({
// list,
// });
// Database Name // Database Name
const dbName = 'lateinicus'; const dbName = 'lateinicus';
// Connection URL // Connection URL
@ -66,7 +56,6 @@ const password = encodeURIComponent(env["LATEINICUS_USER_PW"]);
next(); next();
}); });
app.use("/api/level", LevelRouter); app.use("/api/level", LevelRouter);
app.use("/api/class", ClassRouter);
app.use("/api/user", UserRouter); app.use("/api/user", UserRouter);
app.post("/api/tracker", async (req, res) => { app.post("/api/tracker", async (req, res) => {
// Did we get any data // Did we get any data
@ -168,27 +157,6 @@ const password = encodeURIComponent(env["LATEINICUS_USER_PW"]);
return; return;
} }
// TODO: Check if the username is profane
// if (profanityFilter.isProfane(username)) {
// res.send({
// error: "451",
// data: {
// msg: "Profane username",
// },
// });
// return;
// }
const matches = profanity.check(username, { substring: true });
if (matches.length > 0) {
res.send({
error: "451",
data: {
msg: "Profane username",
},
});
return;
}
// Check if the user already exists // Check if the user already exists
const checkUser = await db.collection("users").findOne({ const checkUser = await db.collection("users").findOne({
username, username,