[local-api] 🎨 Remove unused message and file GET routes

Summary:
This code is dead and has confused me grepping around the codebase before.

If for some unexpected reason we need these routes back in the future, we
can always extract them from version control. For now the routes we aren't
using are a distraction.

Test Plan: been using Nylas Mail with this local patch all week

Reviewers: evan, halla, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D3833
This commit is contained in:
Christine Spang 2017-02-01 07:31:18 -08:00
parent 32b955ad36
commit 8b9f89ab14
2 changed files with 0 additions and 109 deletions

View file

@ -1,77 +1,7 @@
const Joi = require('joi');
const Serialization = require('../serialization');
module.exports = (server) => {
server.route({
method: 'GET',
path: '/files',
config: {
description: 'Returns an array of file metadata.',
notes: 'Notes go here',
tags: ['files'],
validate: {
query: {
limit: Joi.number().integer().min(1).max(2000).default(100),
offset: Joi.number().integer().min(0).default(0),
},
},
response: {
schema: Joi.array().items(
Serialization.jsonSchema('File')
),
},
},
handler: (request, reply) => {
request.getAccountDatabase().then((db) => {
const {File} = db;
File.findAll({
limit: request.query.limit,
offset: request.query.offset,
}).then((files) => {
reply(Serialization.jsonStringify(files));
})
})
},
});
server.route({
method: 'GET',
path: '/files/{id}',
config: {
description: 'Returns file with specified id.',
notes: 'Notes go here',
tags: ['files'],
validate: {
params: {
id: Joi.string(),
},
},
response: {
schema: Joi.alternatives().try(
Serialization.jsonSchema('File'),
Joi.string()
),
},
},
handler: (request, reply) => {
request.getAccountDatabase().then(({File}) => {
const {params: {id}} = request
File.findOne({where: {id}}).then((file) => {
if (!file) {
return reply.notFound(`File ${id} not found`)
}
return reply(Serialization.jsonStringify(file));
})
.catch((err) => {
request.logger.error(err, 'Error fetching file')
reply(err)
})
})
},
})
server.route({
method: 'GET',
path: '/files/{id}/download',

View file

@ -5,45 +5,6 @@ const {createAndReplyWithSyncbackRequest} = require('../route-helpers');
module.exports = (server) => {
server.route({
method: 'GET',
path: '/messages',
config: {
description: 'Returns all your messages.',
notes: 'Notes go here',
tags: ['messages'],
validate: {
query: {
thread_id: Joi.string(),
limit: Joi.number().integer().min(1).max(2000).default(100),
offset: Joi.number().integer().min(0).default(0),
},
},
response: {
schema: Joi.array().items(
Serialization.jsonSchema('Message')
),
},
},
handler: (request, reply) => {
request.getAccountDatabase().then((db) => {
const {Message, Folder, Label, File} = db;
const wheres = {isDraft: false};
if (request.query.thread_id) {
wheres.threadId = request.query.thread_id;
}
Message.findAll({
limit: request.query.limit,
offset: request.query.offset,
where: wheres,
include: [{model: Folder}, {model: Label}, {model: File}],
}).then((messages) => {
reply(Serialization.jsonStringify(messages));
})
})
},
});
server.route({
method: 'GET',
path: '/messages/{id}',