Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Caballerog/00873208b408eef17f87bcc85f5ff4a5 to your computer and use it in GitHub Desktop.
Save Caballerog/00873208b408eef17f87bcc85f5ff4a5 to your computer and use it in GitHub Desktop.
import {
Middleware,
RoleMiddleware,
ThrottlingMiddleware,
UserExistsMiddleware,
} from "./middlewares";
import { REQUEST_PER_MINUTE, USERS } from "./app.constants";
import { Server } from "./server";
const readline = require("readline-sync");
const server = new Server();
server.register(USERS.ADMIN.email, USERS.ADMIN.password);
server.register(USERS.USER.email, USERS.USER.password);
const middleware: Middleware = new ThrottlingMiddleware(REQUEST_PER_MINUTE);
middleware
.setNextMiddleware(new UserExistsMiddleware(server))
.setNextMiddleware(new RoleMiddleware());
server.setMiddleware(middleware);
while (true) {
let success = false;
do {
console.log("....Autentication Software....");
const email = readline.question("Email: ");
const password = readline.question("Password: ", { hideEchoBack: true });
success = server.logIn(email, password);
} while (!success);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment