]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server.js
OAuth server: first draft
[github/Chocobozzz/PeerTube.git] / server.js
index 72c2e7cd1477f71f2b5dedac80eebde362b379ab..f9925eb247c04afbbcecc6fe1ea5616cced3a69f 100644 (file)
--- a/server.js
+++ b/server.js
@@ -66,13 +66,17 @@ app.use(require('connect-livereload')({
 // Catch sefaults
 require('segfault-handler').registerHandler()
 
-// Static files
-app.use(express.static(path.join(__dirname, '/client'), { maxAge: 0 }))
-
 // API routes
 var api_route = '/api/' + constants.API_VERSION
 app.use(api_route, routes.api)
 
+// Static files
+app.use('/app', express.static(path.join(__dirname, '/client'), { maxAge: 0 }))
+// 404 for static files not found
+app.use('/app/*', function (req, res, next) {
+  res.sendStatus(404)
+})
+
 // Client application
 app.use('/*', function (req, res, next) {
   res.sendFile(path.join(__dirname, 'client/index.html'))
@@ -115,6 +119,14 @@ app.use(function (err, req, res, next) {
   res.sendStatus(err.status || 500)
 })
 
+// TODO: move into initializer
+require('./server/models/users').createClient('coucou', [ 'password' ], function (err, id) {
+  if (err) throw err
+  logger.info('Client id: ' + id)
+
+  require('./server/models/users').createUser('floflo', 'coucou', function () {})
+})
+
 // ----------- Create the certificates if they don't already exist -----------
 peertubeCrypto.createCertsIfNotExist(function (err) {
   if (err) throw err