[ABANDONED] React/Redux front end for the Flexor social network.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
757 B

4 years ago
  1. import { resolve } from 'path'
  2. import { config } from 'dotenv'
  3. import fastify from 'fastify'
  4. import fastifyStatic from 'fastify-static'
  5. import httpProxy from 'fastify-http-proxy'
  6. config()
  7. const server = fastify({
  8. logger: {
  9. level: process.env.LOGGER_LEVEL,
  10. prettyPrint: process.env.LOGGER_PRETTY_PRINT === 'true',
  11. }
  12. })
  13. server.register(httpProxy, {
  14. upstream: process.env.API_URL!,
  15. prefix: '/api',
  16. })
  17. server.register(fastifyStatic, {
  18. root: resolve(__dirname, './app'),
  19. wildcard: false,
  20. })
  21. server.get('/*', {}, (_, reply) => {
  22. reply.sendFile('index.html')
  23. })
  24. const port = parseInt(process.env.PORT!, 10)
  25. server.listen(port, err => {
  26. if (err) {
  27. server.log.error(err)
  28. process.exit(1)
  29. }
  30. })