app.js 914 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. // CommonJs
  2. const fastify = require("fastify")({
  3. logger: true,
  4. });
  5. const { Sequelize } = require("sequelize");
  6. const sequelize = new Sequelize("pcoptimum", "root", "3edc#EDC", {
  7. host: "149.248.57.225",
  8. dialect: "mysql",
  9. });
  10. sequelize
  11. .authenticate()
  12. .then(() => {
  13. console.log("Connection has been established successfully.");
  14. })
  15. .catch((error) => {
  16. console.error("Unable to connect to the database:", error);
  17. });
  18. // Declare a route
  19. fastify.get("/login", function (request, reply) {
  20. reply.send({ hello: "world" });
  21. });
  22. // Run the server!
  23. fastify.listen({ port: 3000 }, function (err, address) {
  24. if (err) {
  25. fastify.log.error(err);
  26. process.exit(1);
  27. }
  28. // Server is now listening on ${address}
  29. });
  30. const hashEmail = (email = "") => {
  31. const [username, domain] = email.split("@");
  32. return `${stringHash(username)}@${domain}`;
  33. };