| 1234567891011121314151617181920212223242526272829303132333435363738 |
- // CommonJs
- const fastify = require("fastify")({
- logger: true,
- });
- const { Sequelize } = require("sequelize");
- const sequelize = new Sequelize("pcoptimum", "root", "3edc#EDC", {
- host: "149.248.57.225",
- dialect: "mysql",
- });
- sequelize
- .authenticate()
- .then(() => {
- console.log("Connection has been established successfully.");
- })
- .catch((error) => {
- console.error("Unable to connect to the database:", error);
- });
- // Declare a route
- fastify.get("/login", function (request, reply) {
- reply.send({ hello: "world" });
- });
- // Run the server!
- fastify.listen({ port: 3000 }, function (err, address) {
- if (err) {
- fastify.log.error(err);
- process.exit(1);
- }
- // Server is now listening on ${address}
- });
- const hashEmail = (email = "") => {
- const [username, domain] = email.split("@");
- return `${stringHash(username)}@${domain}`;
- };
|