forked from overleaf/tags
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.coffee
48 lines (41 loc) · 1.64 KB
/
app.coffee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
metrics = require("metrics-sharelatex")
metrics.initialize("tags")
Settings = require 'settings-sharelatex'
logger = require 'logger-sharelatex'
logger.initialize("tags")
express = require('express')
app = express()
controller = require("./app/js/TagsController")
Path = require("path")
metrics.memory.monitor(logger)
HealthCheckController = require("./app/js/HealthCheckController")
app.configure ()->
app.use express.methodOverride()
app.use express.bodyParser()
app.use metrics.http.monitor(logger)
app.use express.errorHandler()
metrics.injectMetricsRoute(app)
app.get '/user/:user_id/tag', controller.getUserTags
app.post '/user/:user_id/tag', controller.createTag
app.put '/user/:user_id/tag', controller.updateTagUserIds
app.post '/user/:user_id/tag/:tag_id/rename', controller.renameTag
app.del '/user/:user_id/tag/:tag_id', controller.deleteTag
app.post '/user/:user_id/tag/:tag_id/project/:project_id', controller.addProjectToTag
app.post '/user/:user_id/tag/project/:project_id', controller.addProjectToTagName
app.del '/user/:user_id/tag/:tag_id/project/:project_id', controller.removeProjectFromTag
app.del '/user/:user_id/project/:project_id', controller.removeProjectFromAllTags
app.get '/status', (req, res)->
res.send('tags sharelatex up')
app.get '/health_check', (req, res)->
HealthCheckController.check (err)->
if err?
logger.err err:err, "error performing health check"
res.send 500
else
res.send 200
app.get '*', (req, res)->
res.send 404
host = Settings.internal?.tags?.host || "localhost"
port = Settings.internal?.tags?.port || 3012
app.listen port, host, ->
logger.info "tags starting up, listening on #{host}:#{port}"