|
@@ -98,8 +98,8 @@ const uploadTrack = require('multer')({ dest: uploadTrackPath, fieldSize: 1024*
|
|
|
console.log(printSchema(schema))
|
|
|
|
|
|
const app = express();
|
|
|
- app.use(express.static('public'));
|
|
|
app.use(cors())
|
|
|
+ app.use(express.static('public'));
|
|
|
app.use('/graphql', express_graphql(jwtGQL({anonSchema, anonResolvers, schema, createContext: getModels, graphiql: true, secret: jwtSecret})))
|
|
|
|
|
|
|
|
@@ -111,6 +111,10 @@ const uploadTrack = require('multer')({ dest: uploadTrackPath, fieldSize: 1024*
|
|
|
|
|
|
let {models: {Image }} = await getModels(decoded.sub)
|
|
|
let image = await Image.fromFileData(req.file)
|
|
|
+ if (image.error){
|
|
|
+ res.end(JSON.stringify(image))
|
|
|
+ return
|
|
|
+ }
|
|
|
res.end(JSON.stringify({_id: image._id, url: image.url}))
|
|
|
}
|
|
|
else {
|
|
@@ -121,12 +125,17 @@ const uploadTrack = require('multer')({ dest: uploadTrackPath, fieldSize: 1024*
|
|
|
|
|
|
app.post('/track', uploadTrack.single('track'), async (req, res, next) => {
|
|
|
let decoded;
|
|
|
- console.log('wtf')
|
|
|
if (decoded = jwtCheck(req, jwtSecret)){
|
|
|
console.log('SOME UPLOAD OF TRACK', decoded, req.file)
|
|
|
|
|
|
let {models: { Track }} = await getModels(decoded.sub)
|
|
|
let track = await Track.fromFileData(req.file)
|
|
|
+
|
|
|
+ if (track.error){
|
|
|
+ console.log('error', track.error)
|
|
|
+ res.end(JSON.stringify(track))
|
|
|
+ return
|
|
|
+ }
|
|
|
res.end(JSON.stringify({_id: track._id, url: track.url}))
|
|
|
}
|
|
|
else {
|