{"version":3,"file":"start.cjs","names":[],"sources":["../../src/bin/start.ts"],"sourcesContent":["#!/usr/bin/env node\n'use strict';\n\nimport express, { type Express } from 'express';\nimport { Server } from 'http';\n\nimport FitnessFirstIcalProxy from '../lib/index.js';\n\nclass AppServer {\n    private app: Express;\n\n    private server: Server;\n    constructor() {\n        this.app = express();\n\n        this.setupRoutes();\n        this.server = this.app.listen(process.env.PORT || 8080);\n\n        process.on('SIGINT', () => this.stop());\n        process.on('SIGTERM', () => this.stop());\n    }\n\n    static run() {\n        new AppServer();\n    }\n\n    setupRoutes() {\n        this.app.get('/ping', (req, res) => {\n            res.send('pong');\n        });\n\n        this.app.get('/ical', (req, res) => {\n            FitnessFirstIcalProxy.request(req.query).then((calendar) => {\n                res.writeHead(200, {\n                    'Content-Disposition':\n                        'attachment; filename=\"calendar.ics\"',\n                    'Content-Type': 'text/calendar; charset=utf-8',\n                });\n\n                res.end(calendar.toString());\n            });\n        });\n    }\n\n    async stop() {\n        await new Promise((cb) => this.server.close(cb));\n\n        process.exit();\n    }\n}\n\nAppServer.run();\n"],"mappings":";mIAmDA,MA3CM,CAAU,CACZ,IAEA,OACA,aAAc,CACV,KAAK,KAAA,EAAA,EAAA,QAAA,CAAc,EAEnB,KAAK,YAAY,EACjB,KAAK,OAAS,KAAK,IAAI,OAAO,QAAQ,IAAI,MAAQ,IAAI,EAEtD,QAAQ,GAAG,aAAgB,KAAK,KAAK,CAAC,EACtC,QAAQ,GAAG,cAAiB,KAAK,KAAK,CAAC,CAC3C,CAEA,OAAO,KAAM,CACT,IAAI,CACR,CAEA,aAAc,CACV,KAAK,IAAI,IAAI,SAAU,EAAK,IAAQ,CAChC,EAAI,KAAK,MAAM,CACnB,CAAC,EAED,KAAK,IAAI,IAAI,SAAU,EAAK,IAAQ,CAChC,EAAsB,QAAQ,EAAI,KAAK,CAAC,CAAC,KAAM,GAAa,CACxD,EAAI,UAAU,IAAK,CACf,sBACI,sCACJ,eAAgB,8BACpB,CAAC,EAED,EAAI,IAAI,EAAS,SAAS,CAAC,CAC/B,CAAC,CACL,CAAC,CACL,CAEA,MAAM,MAAO,CACT,MAAM,IAAI,QAAS,GAAO,KAAK,OAAO,MAAM,CAAE,CAAC,EAE/C,QAAQ,KAAK,CACjB,CACJ,EAEU,IAAI"}