How to use checkAccess method in Cypress

Best JavaScript code snippet using cypress

routes.js

Source:routes.js Github

copy

Full Screen

1// ROUTE: routes.js 2// utils3var _ = require('lodash');4var fs = require('fs-extra');5var gm = require('gm');6var kue = require('kue');7var fss = require("q-io/fs");8var zlib = require('zlib');9var uuid = require('node-uuid');10var util = require('util');11var utf8 = require("utf8");12var mime = require("mime");13var exec = require('child_process').exec;14var dive = require('dive');15var async = require('async');16var carto = require('carto');17var colors = require('colors');18var crypto = require('crypto');19var fspath = require('path');20var request = require('request');21var nodepath = require('path');22var formidable = require('formidable');23var nodemailer = require('nodemailer');24var uploadProgress = require('node-upload-progress');25var mapnikOmnivore = require('mapnik-omnivore');26var errorHandler = require('../middleware/error-handler')();27var analyticsHandler = require('../middleware/analytics-handler')();28// api29var api = require('../api/api');30// function exports31module.exports = function(app) {32 // define apiDocs tokens33 /**34 * @apiDefine token35 * @apiParam {String} access_token A valid access token36 * @apiError {json} Unauthorized The <code>access_token</code> is invalid. (403)37 * @apiErrorExample {json} Error-Response:38 * Error 401: Unauthorized39 * {40 * "error": "Invalid access token."41 * }42 */43 // link app44 api.app = app;45 // authenticate shorthand46 var checkAccess = api.token.authenticate;47 // ================================48 // HOME PAGE (with login links) ===49 // ================================50 app.get('/', analyticsHandler, api.portal.getBase, errorHandler);51 52 /**53 * @api {get} /v2/portal Get portal store54 * @apiName getPortal55 * @apiGroup User56 * @apiUse token57 *58 * @apiSuccess {object} Projects Projects that user have access to59 * @apiSuccess {object} Datasets Datasets that user owns or have access to60 * @apiSuccess {object} Contacts Contacts that user has in contact list61 */62 // =====================================63 // GET PORTAL =========================64 // =====================================65 app.get('/v2/portal', checkAccess, analyticsHandler, api.portal.getPortal, errorHandler);66 67 /**68 * @api {post} /v2/projects/create Create a project69 * @apiName create70 * @apiGroup Project71 * @apiUse token72 * @apiParam {String} name Name of project73 * @apiParam {Object} [access] Access object74 * @apiParam {String} [description] Description of project75 * @apiParam {String} [keywords] Keywords of project76 * @apiParam {Object} [position] Position of project77 * 78 * @apiSuccess {JSON} Project JSON object of the newly created project79 * @apiError {json} Bad_request name doesn't exist in request body (400)80 * @apiErrorExample {json} Error-Response:81 * Error 400: Bad request82 * {83 * "error": {84 * "message": "Missing information. Check out https://github.com/mapic/mapic for details on the API.",85 * "code": "400",86 * "errors": {87 * "missingRequiredFields": ['name']88 * }89 * }90 * }91 */92 // =====================================93 // CREATE NEW PROJECT =================94 // =====================================95 app.post('/v2/projects/create', checkAccess, analyticsHandler, api.project.create, errorHandler);96 /**97 * @api {post} /v2/projects/delete Delete a project98 * @apiName delete99 * @apiGroup Project100 * @apiUse token101 * @apiParam {String} project_id Uuid of project102 * @apiSuccess {String} project ID of deleted project103 * @apiSuccess {Boolean} deleted True if successful104 * @apiSuccessExample {json} Success-Response:105 * {106 * "project": "project-o121l2m-12d12dlk-addasml",107 * "deleted": true108 * }109 * @apiError {json} Bad_request project_id doesn't exist in request body (400)110 * @apiErrorExample {json} Error-Response:111 * Error 400: Bad request112 * {113 * "error": {114 * "message": "Missing information. Check out https://github.com/mapic/mapic for details on the API.",115 * "code": "400",116 * "errors": {117 * "missingRequiredFields": ['project_id']118 * }119 * }120 * }121 * @apiError {json} Not_found If project doesn't exist(404)122 * @apiErrorExample {json} Error-Response:123 * Error 404: Not found124 * {125 * "error": {126 * "message": "No such project.",127 * "code": "404"128 * }129 * }130 */131 // =====================================132 // DELETE PROJECT ====================133 // =====================================134 app.post('/v2/projects/delete', checkAccess, analyticsHandler, api.project.deleteProject, errorHandler);135 /**136 * @api {get} /v2/projects/public Get a public project137 * @apiName get public project138 * @apiGroup Project139 * @apiUse token140 * @apiParam {String} username Username141 * @apiParam {String} project_slug Project slug142 * @apiSuccess {JSON} Project JSON object of the newly created project143 * @apiSuccessExample {json} Success-Response:144 * {145 * _id: '56af8403c608bbce6616d291',146 * lastUpdated: '2016-02-01T16:12:51.390Z',147 * created: '2016-02-01T16:12:51.390Z',148 * createdBy: 'uuid-mocha-test-project',149 * uuid: 'uuid-mocha-test-project_public',150 * etc..151 * }152 * @apiError {json} Bad_request username or project_slug don't exist in request body (400)153 * @apiErrorExample {json} Error-Response:154 * Error 400: Bad request155 * {156 * "error": {157 * "message": "Missing information. Check out https://github.com/mapic/mapic for details on the API.",158 * "code": "400",159 * "errors": {160 * "missingRequiredFields": ['username', 'project_slug']161 * }162 * }163 * }164 * @apiError {json} Not_found If user with specific username doesn't exist(404)165 * @apiErrorExample {json} Error-Response:166 * Error 404: Not found167 * {168 * "error": {169 * "message": "No such user.",170 * "code": "404"171 * }172 * }173 * @apiError {json} Not_found If project with specific slug doesn't exist(404)174 * @apiErrorExample {json} Error-Response:175 * Error 404: Not found176 * {177 * "error": {178 * "message": "No such project.",179 * "code": "404"180 * }181 * }182 * @apiError {json} Bad_request If project isn't public(404)183 * @apiErrorExample {json} Error-Response:184 * Error 400: Bad request185 * {186 * "error": {187 * "message": "Not a public project.",188 * "code": "400"189 * }190 * }191 */192 // =====================================193 // CHECK THAT PROJECT IS PUBLIC ========194 // =====================================195 app.get('/v2/projects/public', checkAccess, analyticsHandler, api.project.getPublic, errorHandler);196 /**197 * @api {get} /v2/projects/private Get private project198 * @apiName get private project199 * @apiGroup Project200 * @apiUse token201 * @apiParam {String} project_id Project id202 * @apiParam {String} user_access_token User access token203 * @apiSuccess {JSON} emptyObject Just now it is return empty object204 * @apiSuccessExample {json} Success-Response:205 * {206 * }207 * @apiError {json} Bad_request project_id or user_access_token don't exist in request body (400)208 * @apiErrorExample {json} Error-Response:209 * Error 400: Bad request210 * {211 * "error": {212 * "message": "Missing information. Check out https://github.com/mapic/mapic for details on the API.",213 * "code": "400",214 * "errors": {215 * "missingRequiredFields": ['project_id', 'user_access_token']216 * }217 * }218 * }219 */220 // =====================================221 // CHECK THAT PROJECT IS PRIVATE =======222 // =====================================223 app.get('/v2/projects/private', checkAccess, analyticsHandler, api.project.getPrivate, errorHandler);224 /**225 * @api {get} /v2/status Get portal status226 * @apiName status227 * @apiGroup Admin228 * @apiUse token229 *230 * @apiSuccess {json} status Status of portal, versions etc.231 * @apiSuccessExample {json} Success-Response:232 * {233 * "status": {234 * "versions": {235 * "mapic_api": "1.3.5",236 * "postgis": "POSTGIS=2.1.7 r13414 GEOS=3.4.2-CAPI-1.8.2 r3921 PROJ=Rel. 4.8.0, 6 March 2012 GDAL=GDAL 1.10.1, released 2013/08/26 LIBXML=2.9.1 LIBJSON=UNKNOWN TOPOLOGY RASTER",237 * "postgres": "PostgreSQL 9.3.9 on x86_64-unknown-linux-gnu, compiled by gcc (Ubuntu 4.8.2-19ubuntu1) 4.8.2, 64-bit",238 * "mongodb": "3.2.1",239 * "redis": "3.0.6"240 * }241 * }242 * }243 */244 // =====================================245 // GET STATUS ====================246 // =====================================247 app.get('/v2/status', checkAccess, analyticsHandler, api.portal.status, errorHandler);248 249 /**250 * @api {get} /v2/users/token Get access token251 * @apiName access_token252 * @apiGroup User253 * @apiParam {String} username Email or username254 * @apiParam {String} password Password255 * @apiParam {Boolean} [refresh=false] Refresh access token256 *257 * @apiSuccess {JSON} status Access token JSON258 * @apiSuccessExample {JSON} Success-Response:259 * {260 * "access_token":"AMduTdFBlXcBc1PKS5Ot4MZzwGjPhKw3y2LzJwJ0CGz0lpRGhK5xHGMcGLqvrOfY1aBR4M9Y4O126WRr5YSQGNZoLPbN0EXMwlRD0ajCqsd4MRr55UpfVYAfrLRL9i0tuglrtGYVs2iT8bl75ZVfYnbDl4Vjp4ElQoWqf6XdqMsIr25XxO5cZB9NRRl3mxA8gWRzCd5bvgZFZTWa6Htx5ugRqwWiudc8lbWNDCx85ms1up94HLKrQXoGMC8FVgf4",261 * "expires_in":"36000",262 * "token_type":"Bearer"263 * }264 * @apiError {json} Bad_request username and email or password don't exist in request body (400)265 * @apiErrorExample {json} Error-Response:266 * Error 400: Bad request267 * {268 * "error": {269 * "message": "Missing information. Check out https://github.com/mapic/mapic for details on the API.",270 * "code": "400",271 * "errors": {272 * "missingRequiredFields": ['username and email', 'password']273 * }274 * }275 * }276 * @apiError {json} Not_found If user doesn't exist(404)277 * @apiErrorExample {json} Error-Response:278 * Error 404: Not found279 * {280 * "error": {281 * "message": "No such user.",282 * "code": "404"283 * }284 * }285 * @apiError {json} Bad_request Wrong password (400)286 * @apiErrorExample {json} Error-Response:287 * Error 400: Bad request288 * {289 * "error": {290 * "message": "Invalid credentials.",291 * "code": "400"292 * }293 * }294 */295 // ================================296 // GET TOKEN FROM PASSWORD ========297 // ================================298 app.get('/v2/users/token', api.token.getTokenFromPassword, errorHandler);299 app.post('/v2/users/token', api.token.getTokenFromPassword, errorHandler);300 /**301 * @api {post} /v2/users/token/refresh Refresh access token302 * @apiName refresh_access_token303 * @apiGroup User304 * @apiUse token305 *306 * @apiSuccess {json} status Access token JSON307 * @apiSuccessExample {json} Success-Response:308 * {309 * "access_token":"AMduTdFBlXcBc1PKS5Ot4MZzwGjPhKw3y2LzJwJ0CGz0lpRGhK5xHGMcGLqvrOfY1aBR4M9Y4O126WRr5YSQGNZoLPbN0EXMwlRD0ajCqsd4MRr55UpfVYAfrLRL9i0tuglrtGYVs2iT8bl75ZVfYnbDl4Vjp4ElQoWqf6XdqMsIr25XxO5cZB9NRRl3mxA8gWRzCd5bvgZFZTWa6Htx5ugRqwWiudc8lbWNDCx85ms1up94HLKrQXoGMC8FVgf4",310 * "expires_in":"36000",311 * "token_type":"Bearer"312 * }313 */314 // ================================315 // REFRESH TOKEN ==================316 // ================================317 app.post('/v2/users/token/refresh', checkAccess, api.token.refresh, errorHandler);318 319 /**320 * @api {post} /v2/users/token/check Check access token post321 * @apiName check_access_token post322 * @apiGroup User323 * @apiUse token324 *325 * @apiSuccess {json} status Access token JSON326 * @apiSuccessExample {json} Success-Response:327 * {328 * "_id": "56b083be8dc7e18c0c8c7059",329 * "lastUpdated": "2016-03-10T06:32:10.288Z",330 * "created": "2016-02-02T10:23:58.521Z",331 * "username": "igorz",332 * "createdBy": "user-d526c531-fd78-411c-94c4-f3e8e233ebf9",333 * "lastName": "Ziegler",334 * "firstName": "Igor",335 * "uuid": "user-d526c531-fd78-411c-94c4-f3e8e233ebf9",336 * "__v": 63,337 * "postgis_database": "wpxpokqmrq",338 * "local": {339 * "password": "$2a$08$RGx4FyOEO9N4V201Qu/JyOJ17OpQGl31CuOQxhYkZzGXNehrBcP.C",340 * "email": "icygler@hwdtech.ru"341 * },342 * "files": [343 * "56c3fdc08ac6ec1c005912d0",344 * "56c5674290a3531a6a30bd64",345 * "56b470db440658e25d9b812b",346 * "56b47121440658e25d9b812f",347 * "56b46fc2440658e25d9b8114",348 * "56b471df440658e25d9b8134",349 * "56b47089440658e25d9b811f",350 * "56b46fb1440658e25d9b810f",351 * "56b470ab440658e25d9b8129",352 * "56b46fcd440658e25d9b8119",353 * "56b470a6440658e25d9b8126",354 * "56d3fd6848f7b32b69e9c1c3",355 * "56d4002348f7b32b69e9c1c4",356 * "56d4007b48f7b32b69e9c1c5",357 * "56d4008248f7b32b69e9c1c6",358 * "56e0372ffde316a0380f89a9",359 * "56e03c8b4e57b5d34c44e4f3",360 * "56e114ea3eac7a96780a7ee1"361 * ],362 * "contact_list": [363 * "56b37759b5c269bd7edaa02e",364 * "56b0ae88355d7faf1fc4712d",365 * "56d3de4cdd79f1bb5f83dc17",366 * "56d3e1f8dd79f1bb5f83dc18",367 * "56d6da007d2bee1c0083fa04",368 * "56d6e0177d2bee1c0083fa13"369 * ],370 * "access": {371 * "private_projects": true,372 * "remaining_quota": 200000000,373 * "storage_quota": 200000000,374 * "account_type": "free"375 * },376 * "state": {377 * "lastProject": []378 * },379 * "status": {380 * "contact_requests": []381 * }382 *}383 */384 // ================================385 // CHECK TOKEN ====================386 // ================================387 app.post('/v2/users/token/check', checkAccess, function (req, res, next) {388 res.send(req.user);389 }, errorHandler);390 /**391 * @api {get} /v2/users/token/check Check access token get392 * @apiName check_access_token get393 * @apiGroup User394 * @apiUse token395 *396 * @apiSuccess {json} status Valid status397 * @apiSuccessExample {json} Success-Response:398 * {399 * "valid" : true,400 * "user_id" : "user-random-uuid",401 * "username" : "username"402 * }403 */404 // ================================405 // CHECK TOKEN ====================406 // ================================407 app.get('/v2/users/token/check', checkAccess, function (req, res, next) {408 res.send({409 valid : true,410 user_id : req.user.uuid,411 username : req.user.username412 });413 }, errorHandler);414 415 /**416 * @api {get} /v2/users/session Check if already logged in (browser-only)417 * @apiName user session418 * @apiGroup User419 *420 * @apiSuccess {json} status Access token JSON421 * @apiSuccessExample {json} Success-Response:422 * {423 * "access_token":"AMduTdFBlXcBc1PKS5Ot4MZzwGjPhKw3y2LzJwJ0CGz0lpRGhK5xHGMcGLqvrOfY1aBR4M9Y4O126WRr5YSQGNZoLPbN0EXMwlRD0ajCqsd4MRr55UpfVYAfrLRL9i0tuglrtGYVs2iT8bl75ZVfYnbDl4Vjp4ElQoWqf6XdqMsIr25XxO5cZB9NRRl3mxA8gWRzCd5bvgZFZTWa6Htx5ugRqwWiudc8lbWNDCx85ms1up94HLKrQXoGMC8FVgf4",424 * "expires_in":"36000",425 * "token_type":"Bearer"426 * }427 */428 // ================================429 // CHECK SESSION ==================430 // ================================431 app.get('/v2/users/session', analyticsHandler, api.token.checkSession, errorHandler);432 /**433 * @api {post} /v2/log/error Log error434 * @apiName log error435 * @apiGroup Log436 * @apiUse token437 * @apiParam {String} message Error message438 * @apiParam {String} file File439 * @apiParam {String} line Line440 * @apiParam {String} stack Stack441 * @apiSuccess {json} empty Empty object442 * @apiSuccessExample {json} Success-Response:443 * Error 200: SyntaxError: Unexpected end of input444 */445 // =====================================446 // ERROR LOGGING =======================447 // =====================================448 app.post('/v2/log/error', checkAccess, analyticsHandler, api.error.clientLog, errorHandler);449 // =====================================450 // ANALYTICS ===================451 // =====================================452 app.post('/v2/log', checkAccess, analyticsHandler, api.analytics.set, errorHandler);453 // =====================================454 // ANALYTICS ===================455 // =====================================456 app.get('/v2/log', checkAccess, analyticsHandler, api.analytics.get, errorHandler);457 // =====================================458 // RESUMABLE.js UPLOADS ================459 // =====================================460 // app.get('/api/data/upload/chunked', checkAccess, function (req, res) {461 app.get('/v2/data/import/chunked', checkAccess, analyticsHandler, api.upload.chunkedCheck, errorHandler);462 // =====================================463 // UPLOAD DATA IN CHUNKS (RESUMABLE) === 464 // =====================================465 // app.post('/api/data/upload/chunked', checkAccess, api.upload.chunkedUpload);466 app.post('/v2/data/import/chunked', checkAccess, analyticsHandler, api.upload.chunkedUpload, errorHandler);467 // // =====================================468 // // RESUMABLE.js UPLOADS ================469 // // =====================================470 // app.get('/download/:identifier', checkAccess, function (req, res) {471 // api.upload.chunkedIdent(req, res);472 // });473 474 /**475 * @api {get} /v2/data/import Get upload 476 * @apiName get upload477 * @apiGroup Upload478 * @apiUse token479 * @apiParam {String} file_id480 * @apiSuccess {Object} file Upload file481 * @apiSuccess {Object} layer Related layer482 * @apiSuccess {Object} project Related project483 * @apiSuccessExample {json} Success-Response:484 * {485 * file: {486 * _id: '56af0e566f8ca08221ee2ca7',487 * lastUpdated: '2016-02-01T07:50:46.730Z',488 * created: '2016-02-01T07:50:46.726Z',489 * dataSize: '109770',490 * type: 'postgis',491 * originalName: 'shapefile.zip',492 * name: 'shapefile',493 * createdBy: 'uuid-mocha-test-project',494 * uuid: 'file_tzcqhdaecyhmqraulgby',495 * __v: 0,496 * access: {497 * clients: [],498 * projects: [],499 * users: []500 * },501 * data: {502 * image: [Object],503 * postgis: [Object]504 * },505 * format: [],506 * keywords: [],507 * files: []508 * },509 * layer: null510 * }511 * @apiError {json} Bad_request file_id do not exist in request body (400)512 * @apiErrorExample {json} Error-Response:513 * Error 400: Bad request514 * {515 * "error": {516 * "message": "Missing information. Check out https://github.com/mapic/mapic for details on the API.",517 * "code": "400",518 * "errors": {519 * "missingRequiredFields": ['file_id']520 * }521 * }522 * }523 * @apiError {json} Not_found If file doesn't upload(404)524 * @apiErrorExample {json} Error-Response:525 * Error 404: Not found526 * {527 * "error": {528 * "message": "no such upload status id",529 * "code": "404"530 * }531 * }532 */533 // =====================================534 // GET UPLOAD ==========================535 // =====================================536 // app.get('/api/upload/get', checkAccess, api.upload.getUpload, errorHandler);537 app.get('/v2/data/import', checkAccess, analyticsHandler, api.upload.getUpload, errorHandler);538 /**539 * @api {post} /v2/data/import Import data540 * @apiName import541 * @apiGroup Data542 * @apiUse token543 * @apiParam {Buffer} data File buffer544 *545 * @apiSuccess {json} status Upload Status JSON546 * @apiSuccessExample {json} Success-Response:547 * {548 * "file_id":"file_fxqzngykgzjxtsunulti",549 * "user_id":"test-user-uuid",550 * "filename":"shapefile.zip",551 * "timestamp":1453063189097,552 * "status":"Processing",553 * "size":109770,554 * "upload_success":true,555 * "error_code":null,556 * "error_text":null557 * }558 */559 // =====================================560 // IMPORT DATA to POSTGIS ==============561 // =====================================562 // change to /api/data/import563 // app.post('/api/import', checkAccess, function (req, res) {564 app.post('/v2/data/import', checkAccess, analyticsHandler, api.upload.upload, errorHandler);565 app.post('/v2/data/import/csv', checkAccess, analyticsHandler, api.upload.uploadCSV, errorHandler);566 // todo: document567 // =====================================568 // GET UPLOAD STATUS ===================569 // =====================================570 // change to /api/import/status571 // app.get('/api/import/status', checkAccess, api.upload.getUploadStatus);572 app.get('/v2/data/status', checkAccess, api.upload.getUploadStatus, errorHandler);573 app.post('/v2/data/status', checkAccess, api.upload.setUploadStatus, errorHandler);574 /**575 * @apiIgnore576 * @api {get} /api/joinbeta Joinbeta577 * @apiUse apiSampleRequest578 * @apiName Joinbeta579 * @apiGroup Admin580 * @apiUse token581 * @apiParam {Buffer} email User email582 *583 * @apiSuccess {json} status Upload Status JSON584 * @apiSuccessExample {json} Success-Response:585 * {586 * }587 */588 // =====================================589 // JOIN BETA MAIL ======================590 // =====================================591 app.get('/api/joinbeta', analyticsHandler, api.portal.joinBeta, errorHandler, errorHandler);592 /**593 * @api {post} /v2/projects/update Update project594 * @apiName update595 * @apiGroup Project596 * @apiUse token597 * @apiParam {String} project_id Uuid of project which should be update598 * @apiParam {String} [logo] New logo of project599 * @apiParam {String} [header] New header of project600 * @apiParam {Array} [baseLayers] New baseLayers of project601 * @apiParam {Object} [position] New position of project602 * @apiParam {Object} [bounds] New bounds of project603 * @apiParam {Array} [layermenu] New layermenu of project604 * @apiParam {Array} [folders] New folders of project605 * @apiParam {Object} [controls] New controls of project606 * @apiParam {String} [description] New description of project607 * @apiParam {Array} [keywords] New keywords of project608 * @apiParam {String} [colorTheme] New colorTheme of project609 * @apiParam {String} [title] New title of project610 * @apiParam {String} [slug] New slug of project611 * @apiParam {Object} [connectedAccounts] New connectedAccounts of project612 * @apiParam {Object} [settings] New settings of project613 * @apiParam {Array} [categories] New categories of project614 * @apiParam {Boolean} [thumbCreated] New thumbCreated of project615 * @apiParam {String} [state] New state of project616 * @apiParam {Array} [pending] New pending of project617 * @apiSuccess {json} access Project access object618 * @apiSuccessExample {json} Success-Response:619 * {620 * updated: ['logo', 'header', etc...],621 * project: {622 * _id: '56af0e566f8ca08221ee2ca7',623 * lastUpdated: '2016-02-01T07:50:46.730Z',624 * created: '2016-02-01T07:50:46.726Z',625 * etc...626 * }627 * }628 * @apiError {json} Bad_request project_id doesn't not exist in request body (400)629 * @apiErrorExample {json} Error-Response:630 * Error 400: Bad request631 * {632 * "error": {633 * "message": "Missing information. Check out https://github.com/mapic/mapic for details on the API.",634 * "code": "400",635 * "errors": {636 * "missingRequiredFields": ['project_id']637 * }638 * }639 * }640 * @apiError {json} Not_found If project doesn't exist(404)641 * @apiErrorExample {json} Error-Response:642 * Error 404: Not found643 * {644 * "error": {645 * "message": "No such project.",646 * "code": "404"647 * }648 * }649 * @apiError {json} Bad_request User haven't access to the project (400)650 * @apiErrorExample {json} Error-Response:651 * Error 400: Bad request652 * {653 * "error": {654 * "message": "No access.",655 * "code": "400"656 * }657 * }658 */659 // =====================================660 // UPDATE PROJECT ======================661 // =====================================662 app.post('/v2/projects/update', checkAccess, analyticsHandler, api.project.update, errorHandler);663 /**664 * @api {post} /v2/projects/slug/unique Unique project665 * @apiName unique666 * @apiGroup Project667 * @apiUse token668 * @apiSuccess {Boolean} unique Project access object669 * @apiSuccessExample {json} Success-Response:670 * {671 * updated: ['logo', 'header', etc...],672 * project: {673 * _id: '56af0e566f8ca08221ee2ca7',674 * lastUpdated: '2016-02-01T07:50:46.730Z',675 * created: '2016-02-01T07:50:46.726Z',676 * etc...677 * }678 * }679 */680 // =====================================681 // CHECK UNIQUE SLUG ===================682 // =====================================683 app.post('/v2/projects/slug/unique', checkAccess, analyticsHandler, api.project.checkUniqueSlug, errorHandler);684 685 app.post('/v2/projects/slug/available', checkAccess, analyticsHandler, api.project.getAvailableSlug, errorHandler);686 /**687 * @api {post} /v2/projects/access Set project access object688 * @apiName set access689 * @apiGroup Project690 * @apiUse token691 * @apiParam {String} project Uuid of project692 * @apiParam {Object} access Access object693 * @apiSuccess {json} project Project with updated access694 * @apiSuccessExample {json} Success-Response:695 * {696 * _id: '56af0e566f8ca08221ee2ca7',697 * lastUpdated: '2016-02-01T07:50:46.730Z',698 * created: '2016-02-01T07:50:46.726Z',699 * etc...700 * }701 * @apiError {json} Bad_request access or project do not exist in request body (400)702 * @apiErrorExample {json} Error-Response:703 * Error 400: Bad request704 * {705 * "error": {706 * "message": "Missing information. Check out https://github.com/mapic/mapic for details on the API.",707 * "code": "400",708 * "errors": {709 * "missingRequiredFields": ['access', 'project']710 * }711 * }712 * }713 * @apiError {json} Bad_request User doesn't have access to change access rights of project (400)714 * @apiErrorExample {json} Error-Response:715 * Error 400: Bad request716 * {717 * "error": {718 * "message": "No access.",719 * "code": "400"720 * }721 * }722 * @apiError {json} Not_found If project doesn't exist(404)723 * @apiErrorExample {json} Error-Response:724 * Error 404: Not found725 * {726 * "error": {727 * "message": "No such project.",728 * "code": "404"729 * }730 * }731 */732 // =====================================733 // SET ACCESS ==========================734 // =====================================735 // app.post('/api/project/setAccess', checkAccess, function (req,res) {736 app.post('/v2/projects/access', checkAccess, analyticsHandler, api.project.setAccess, errorHandler);737 /**738 * @api {post} /v2/users/invite/project Add invites739 * @apiName add invites740 * @apiGroup Project741 * @apiUse token742 * @apiParam {String} project Uuid of project743 * @apiParam {Object} access Access object744 * @apiSuccess {json} access Project access object745 * @apiSuccessExample {json} Success-Response:746 * {747 * read: ['test'],748 * edit: ['uuid-mocha-test-project'],749 * options: {750 * share: true,751 * download: false,752 * isPublic: false753 * }754 *}755 * @apiError {json} Bad_request access or project do not exist in request body (400)756 * @apiErrorExample {json} Error-Response:757 * Error 400: Bad request758 * {759 * "error": {760 * "message": "Missing information. Check out https://github.com/mapic/mapic for details on the API.",761 * "code": "400",762 * "errors": {763 * "missingRequiredFields": ['access', 'project']764 * }765 * }766 * }767 * @apiError {json} Not_found If project doesn't exist(404)768 * @apiErrorExample {json} Error-Response:769 * Error 404: Not found770 * {771 * "error": {772 * "message": "No such project.",773 * "code": "404"774 * }775 * }776 */777 // =====================================778 // INVITE USERS TO PROJECT =============779 // =====================================780 // change route to /api/project/invite781 app.post('/v2/users/invite/project', checkAccess, analyticsHandler, api.project.addInvites, errorHandler);782 // list users783 app.get('/v2/users/list', checkAccess, api.user.listUsers, errorHandler);784 /**785 * @api {post} /v2/hashes Set project hash786 * @apiName Set hash787 * @apiGroup Project788 * @apiUse token789 * @apiParam {String} project_id Uuid of project790 * @apiParam {Bollean} saveState Save prject state flag791 * @apiParam {Object} hash Hash object792 * @apiSuccess {Object} error Error object793 * @apiSuccess {Object} hash Created hash794 * @apiSuccessExample {json} Success-Response:795 * {796 * error: null,797 * hash: {798 * __v: 0,799 * lastUpdated: '2016-02-12T10:22:20.535Z',800 * created: '2016-02-12T10:22:20.535Z',801 * project: 'uuid-mocha-test-project-for-hash-set',802 * createdByName: 'mocha test',803 * createdBy: 'uuid-mocha-test-project',804 * id: 'some id',805 * uuid: 'hash-1225da89-7d03-4df9-981c-804cd119a1f8',806 * _id: '56bdb25c78c5e3cd164f1f1d',807 * layers: ['some layer'],808 * position: {809 * lat: '1',810 * lng: '1',811 * zoom: '1'812 * }813 * }814 * }815 * @apiError {json} Bad_request project_id or saveState or hash or hash.position or hash.layers or hash.id don't not exist in request body (400)816 * @apiErrorExample {json} Error-Response:817 * Error 400: Bad request818 * {819 * "error": {820 * "message": "Missing information. Check out https://github.com/mapic/mapic for details on the API.",821 * "code": "400",822 * "errors": {823 * "missingRequiredFields": ['project_id', 'saveState', 'hash', 'hash.position', 'hash.layers', 'hash.id']824 * }825 * }826 * }827 */828 // =====================================829 // SET PROJECT HASH ====================830 // =====================================831 // change to /api/project/setHash832 // app.post('/api/project/hash/set', checkAccess, api.project.setHash, errorHandler);833 app.post('/v2/hashes', checkAccess, analyticsHandler, api.project.setHash, errorHandler);834 /**835 * @api {get} /v2/hashes Get project hash836 * @apiName Get hash837 * @apiGroup Project838 * @apiUse token839 * @apiParam {String} project_id Uuid of project840 * @apiParam {String} id Hash id841 * @apiSuccess {Object} error Error object842 * @apiSuccess {Object} hash Hash object843 * @apiSuccessExample {json} Success-Response:844 * {845 * error: null,846 * hash: {847 * _id: '56bdc6fbc7ec6af66dfc92f0',848 * lastUpdated: '2016-02-12T11:50:19.231Z',849 * created: '2016-02-12T11:50:19.231Z',850 * id: 'some hash id',851 * project: 'some project id',852 * uuid: 'test_mocha_hash',853 * __v: 0,854 * layers: []855 * }856 * }857 * @apiError {json} Bad_request project_id or project_id or id don't not exist in request body (400)858 * @apiErrorExample {json} Error-Response:859 * Error 400: Bad request860 * {861 * "error": {862 * "message": "Missing information. Check out https://github.com/mapic/mapic for details on the API.",863 * "code": "400",864 * "errors": {865 * "missingRequiredFields": ['project_id', 'id']866 * }867 * }868 * }869 * @apiError {json} Not_found If hash doesn't exist(404)870 * @apiErrorExample {json} Error-Response:871 * Error 404: Not found872 * {873 * "error": {874 * "message": "No such hash.",875 * "code": "404"876 * }877 * }878 */879 // =====================================880 // GET PROJECT HASH ====================881 // =====================================882 // change to /api/project/getHash883 // app.post('/api/project/hash/get', checkAccess, api.project.getHash, errorHandler);884 app.get('/v2/hashes', checkAccess, analyticsHandler, api.project.getHash, errorHandler);885 /**886 * // this route is deprecated887 * @apiIgnore 888 * @api {post} /api/project/uploadlogo Upload project logo889 * @apiName Upload project logo890 * @apiGroup Project891 * @apiUse token892 * @apiParam {String} image_id Image id893 * @apiParam {String} resumableIdentifier Resumable identifier894 * @apiSuccess {Object} error Error object895 * @apiSuccess {String} image Image uuid 896 * @apiSuccessExample {json} Success-Response:897 * '56bdc6fbc7ec6af66dfc92f0'898 * @apiError {json} Bad_request image_id or resumableIdentifier or id don't not exist in request body (400)899 * @apiErrorExample {json} Error-Response:900 * Error 400: Bad request901 * {902 * "error": {903 * "message": "Missing information. Check out https://github.com/mapic/mapic for details on the API.",904 * "code": "400",905 * "errors": {906 * "missingRequiredFields": ['image_id', 'resumableIdentifier']907 * }908 * }909 * }910 */911 // =====================================912 // UPLOAD PROJECT LOGO ================913 // =====================================914 // change to /api/project/setLogo915 // app.post('/api/project/uploadlogo', checkAccess, api.upload.projectLogo, errorHandler);916 // todo: remove, deprecated917 // =====================================918 // UPLOAD IMAGE ========================919 // =====================================920 // change to /api/import/image921 app.post('/api/upload/image', checkAccess, analyticsHandler, api.upload.image, errorHandler);922 // =====================================923 // SERVE STATIC FILES SECURELY ========924 // =====================================925 // special route, don't touch for now926 app.get('/images/*', checkAccess, analyticsHandler, api.file.sendImage, errorHandler);927 // =====================================928 // SERVE STATIC FILES SECURELY ========929 // =====================================930 // change to /api/... 931 // special route, don't touch for now932 app.get('/pixels/fit/*', checkAccess, analyticsHandler, api.pixels.serveFitPixelPerfection, errorHandler);933 // =====================================934 // SERVE STATIC FILES SECURELY ========935 // =====================================936 // change to /api/... 937 app.get('/pixels/image/*', checkAccess, analyticsHandler, api.pixels.serveImagePixelPerfection, errorHandler);938 // =====================================939 // SERVE STATIC FILES SECURELY ========940 // =====================================941 // change to /api/... 942 app.get('/pixels/screenshot/*', api.pixels.serveScreenshot, errorHandler);943 // =====================================944 // SERVE STATIC FILES SECURELY ========945 // =====================================946 // change to /api/... 947 app.get('/pixels/*', checkAccess, analyticsHandler, api.pixels.servePixelPerfection, errorHandler);948 // =====================================949 // GET MAPBOX ACCOUNT ==================950 // =====================================951 // change to /api/tools/mapbox/get952 app.post('/api/util/getmapboxaccount', checkAccess, analyticsHandler, api.provider.mapbox.getAccount, errorHandler);953 954 // =====================================955 // CREATE SNAPSHOT =====================956 // =====================================957 // create snapshot of current map958 // app.post('/api/util/snapshot', checkAccess, function (req, res) {959 // app.post('/v2/static/screen', checkAccess, api.pixels.createSnapshot);960 app.post('/v2/static/screen', checkAccess, analyticsHandler, api.pixels.snap, errorHandler);961 /**962 * @api {post} /v2/legends/create Create legend963 * @apiName Create legend964 * @apiGroup Legends965 * @apiUse token966 * @apiParam {String} fileUuid File uuid967 * @apiParam {String} cartoid Carto css id968 * @apiParam {String} layerUuid Layer uuid969 * @apiSuccess {Array} legends array970 * @apiSuccessExample {String} Success-Response:971 * [972 * {973 * base64: uri,974 * key: key,975 * value: value,976 * id: id,977 * fileUuid: fileUuid,978 * cartoid: cartoid,979 * on: true980 * },981 * etc...982 * ]983 * @apiError {json} Bad_request If fileUuid or cartoid or layerUuid don't not exist in request body (400)984 * @apiErrorExample {json} Error-Response:985 * Error 400: Bad request986 * {987 * "error": "Missing information.4"988 * }989 */990 // =====================================991 // AUTO-CREATE LEGENDS =================992 // =====================================993 // change to /api/layer/legends/create994 // app.post('/api/layer/createlegends', checkAccess, function (req, res) {995 app.post('/v2/legends/create', checkAccess, analyticsHandler, api.legend.create, errorHandler);996 // todo: remove, deprecated997 // =====================================998 // GET GEOJSON FILES ===================999 // =====================================1000 // change to /api/data/get ... 1001 // todo: perhaps improve this, put all downloads together, with type/format in query/form.. todo later1002 // app.post('/api/geojson', checkAccess, function (req,res) {1003 // api.file.getGeojsonFile(req, res);1004 // });1005 1006 // todo: remove, deprecated1007 // =====================================1008 // GET FILE DOWNLOAD ===================1009 // =====================================1010 // change to /api/data/download1011 app.get('/api/file/download', checkAccess, analyticsHandler, api.file.download, errorHandler);1012 // todo: remove, deprecated (will be removed with new raster import (branch: postgis_raster))1013 // =====================================1014 // GET FILE DOWNLOAD ===================1015 // =====================================1016 // change to /api/tools/tilecount1017 // app.get('/api/util/getTilecount', checkAccess, api.geo.getTilecount);1018 /**1019 * @api {post} /v2/layers/carto/json Return carto css1020 * @apiName json2carto1021 * @apiGroup Geo1022 * @apiUse token1023 * @apiParam {Object} style Style object parameter1024 * @apiSuccess {String} cartoCss Carto css1025 * @apiSuccessExample {String} Success-Response:1026 * "@polygon_opacity: 1;1027 * #layer {1028 *1029 * polygon-opacity: @polygon_opacity;1030 *1031 * polygon-fill: red;1032 *1033 * }"1034 * @apiError {json} Bad_request uuid does not exist in request body (400)1035 * @apiErrorExample {json} Error-Response:1036 * Error 400: Bad request1037 * {1038 * "error": {1039 * "message": "Missing style!",1040 * "code": "400",1041 * "errors": {1042 * "missingRequiredFields": ['style']1043 * }1044 * }1045 * }1046 */1047 // =====================================1048 // GET GEOJSON FILES ===================1049 // =====================================1050 // change to /api/tools/json2carto1051 // app.post('/api/geo/json2carto', checkAccess, api.geo.json2carto, errorHandler);1052 app.post('/v2/layers/carto/json', checkAccess, analyticsHandler, api.geo.json2carto, errorHandler);1053 app.post('/v2/layers/carto/custom', checkAccess, analyticsHandler, api.geo.cartoCustom, errorHandler);1054 1055 // get list of wms layers1056 app.get('/v2/layers/wms', checkAccess, analyticsHandler, api.layer.getWMSLayers, errorHandler);1057 1058 /**1059 * @api {post} /v2/data/download Download dataset from file1060 * @apiName Download dataset from file1061 * @apiGroup File1062 * @apiUse token1063 * @apiParam {String} file_id File uuid1064 * @apiSuccess {String} download_status_id Download status id 1065 * @apiSuccess {Boolean} finished True if finished download 1066 * @apiSuccess {String} file_id File uuid1067 * @apiSuccessExample {String} Success-Response: 1068 * {1069 * "download_status_id": "rwurnixh",1070 * "finished": false,1071 * "file_id": "file_agjcpeadohnnxljmblkl"1072 * }1073 */1074 // =====================================1075 // DOWNLOAD DATASET ====================1076 // =====================================1077 // change to /api/data/download (POST/GET routes with same name no problem)1078 // app.post('/api/file/downloadDataset', checkAccess, function (req,res) {1079 app.post('/v2/data/download', checkAccess, analyticsHandler, api.postgis.downloadDatasetFromFile, errorHandler);1080 /**1081 * @api {post} /v2/layers/download Download dataset from layer1082 * @apiName Download dataset from layer1083 * @apiGroup Layer1084 * @apiUse token1085 * @apiParam {String} layer_id Layer uuid1086 * @apiSuccess {String} download_status_id Download status id 1087 * @apiSuccess {Boolean} finished True if finished download 1088 * @apiSuccess {String} file_id Layer uuid1089 * @apiSuccessExample {String} Success-Response: 1090 * {1091 * "download_status_id": "rwurnixh",1092 * "finished": false,1093 * "file_id": "layer-7aacda14-9115-44d0-b8e2-28854129dce5"1094 * }1095 */1096 // =====================================1097 // DOWNLOAD DATASET ====================1098 // =====================================1099 // change to /api/layer/download1100 // app.post('/api/layer/downloadDataset', checkAccess, function (req,res) {1101 app.post('/v2/layers/download', checkAccess, analyticsHandler, api.postgis.downloadDatasetFromLayer, errorHandler);1102 1103 /**1104 * @api {post} /v2/data/update Update a file1105 * @apiName update1106 * @apiGroup File1107 * @apiUse token1108 * @apiParam {String} uuid Uuid of file1109 * @apiParam {String} [name] New name file1110 * @apiParam {String} [description] New description1111 * @apiParam {Array} [keywords] Array of keywords1112 * @apiParam {String} [status] New file status1113 * @apiParam {String} [category] New file category1114 * @apiParam {Number} [version] New file version1115 * @apiParam {String} [copyright] New file copyright1116 * @apiParam {Object} [data] New data object1117 * @apiParam {Array} [styleTemplates] New array of styleTemplates object1118 *1119 * @apiSuccess {Array} updated Array of updated fields1120 * @apiSuccess {Object} file Updated file1121 * @apiSuccessExample {json} Success-Response:1122 * {1123 * "updated": ['name', 'description'],1124 * "file": {1125 * lastUpdated: '2016-01-19T12:49:49.076Z',1126 * created: '2016-01-19T12:49:48.943Z',1127 * ... etc1128 * }1129 * }1130 * @apiError {json} File with uuid <code>uuid</code> doesn't exist. (422)1131 * @apiErrorExample {json} Error-Response:1132 * Error 422: File doesn't exist1133 * {1134 * "error": "bad file uuid"1135 * }1136 */1137 // =====================================1138 // UPDATE FILE =========================1139 // =====================================1140 // change to /api/data/update1141 app.post('/v2/data/update', checkAccess, analyticsHandler, api.file.update, errorHandler);1142 /**1143 * @api {post} /v2/data/create Create file1144 * @apiName create1145 * @apiGroup File1146 * @apiUse token1147 * @apiParam {String} [createdBy] Uuid of created user1148 * @apiParam {String} [createdByName] Name of created user1149 * @apiParam {Array} [files] Array of file ids1150 * @apiParam {Object} [access] Access object with users, projects and clients arrays1151 * @apiParam {String} [name] Name of new file1152 * @apiParam {String} [description] Description of new file1153 * @apiParam {String} [type] Type of new file1154 * @apiParam {Array} [format] Array of strings with formats1155 * @apiParam {String} [dataSize] Data size of new file1156 * @apiParam {Object} [data] Data of new file1157 *1158 * @apiSuccess {Object} file created file1159 * @apiSuccessExample {json} Success-Response:1160 * {1161 * "file": {1162 * lastUpdated: '2016-01-19T12:49:49.076Z',1163 * created: '2016-01-19T12:49:48.943Z',1164 * ... etc1165 * }1166 * }1167 */1168 // =====================================1169 // CREATE DATASET ======================1170 // =====================================1171 app.post('/v2/data/create', checkAccess, api.file.create, errorHandler);1172 /**1173 * @api {post} /v2/data/layers Get layers1174 * @apiName getLayers1175 * @apiGroup File1176 * @apiUse token1177 * @apiParam {String} type Type of file(raster or postgis)1178 * @apiParam {Object} data Object with file_id field for raster files or database_name and table_name for postgis files1179 * @apiSuccess {Array} array of layers1180 * @apiSuccessExample {json} Success-Response:1181 * [1182 * {1183 * uuid: 'layer uuid',1184 * title: 'layer title',1185 * description: 'layer description',1186 * ... etc1187 * }1188 * ]1189 * @apiError {json} Missing required fields. (422)1190 * @apiErrorExample {json} Error-Response:1191 * Error 422: Missing type parameter or database_name and table_name for postgis type1192 * {1193 * "error": "Missing information. Check out https://github.com/mapic/mapic for details on the API."1194 * }1195 * @apiError {json} Missing required fields. (422)1196 * @apiErrorExample {json} Error-Response:1197 * Error 422: Missing file_id for rater type1198 * {1199 * "error": "request body should contains data.file_id"1200 * }1201 */1202 // =====================================1203 // GET LAYERS OF FILE ==================1204 // =====================================1205 // change to /api/data/getLayers1206 app.post('/v2/data/layers', checkAccess, analyticsHandler, api.file.getLayers, errorHandler);1207 /**1208 * @api {post} /v2/data/share Share dataset1209 * @apiName shareDataset1210 * @apiGroup File1211 * @apiUse token1212 * @apiParam {String} dataset File id1213 * @apiParam {Array} users Array of user's ids1214 * @apiSuccess {Object} err Error object1215 * @apiSuccess {Boolean} success1216 * @apiSuccess {Object} file_shared File shared object1217 * @apiSuccess {Array} users_shared_with Shared users1218 * @apiSuccessExample {json} Success-Response:1219 * {1220 * err: null1221 * success: true,1222 * file_shared: {1223 * file_name: 'fileName',1224 * file_uuid: 'fileUuid',1225 * }1226 * users_shared_with : ['userId']1227 * }1228 * @apiError {json} Bad_request dataset or users do not exist in request body (400)1229 * @apiErrorExample {json} Error-Response:1230 * Error 400: Bad request1231 * {1232 * "error": {1233 * "message": "Missing information. Check out https://github.com/mapic/mapic for details on the API.",1234 * "code": "400",1235 * "errors": {1236 * "missingRequiredFields": ['users', 'dataset']1237 * }1238 * }1239 * }1240 * @apiError {json} Not_found file does not exist (404)1241 * @apiErrorExample {json} Error-Response:1242 * Error 404: Not found1243 * {1244 * "error": {1245 * "message": "No such file.",1246 * "code": "404"1247 * }1248 * }1249 */1250 // =====================================1251 // SHARE DATASET =======================1252 // =====================================1253 app.post('/v2/data/share', checkAccess, analyticsHandler, api.file.shareDataset, errorHandler);1254 1255 /**1256 * @api {get} /v2/data/geojson Get vector dataset as GeoJSON1257 * @apiName get dataset as geojson1258 * @apiGroup File1259 * @apiUse token1260 * @apiParam {String} dataset_id Dataset/file id1261 * @apiSuccess {String} geojson GeoJSON representation of dataset1262 */1263 // =====================================1264 // GET GEOJSON OF DATASET ==============1265 // =====================================1266 app.get('/v2/data/geojson', checkAccess, analyticsHandler, api.file.getGeojson, errorHandler); 1267 /**1268 * @api {post} /v2/data/several Get vector dataset as GeoJSON1269 * @apiName get info on several datasets1270 * @apiGroup File1271 * @apiUse token1272 * @apiParam {Array} dataset_ids Dataset/file id1273 * @apiSuccess {Array} datasets Representations of dataset1274 */1275 // =====================================1276 // GET GEOJSON OF DATASET ==============1277 // =====================================1278 app.post('/v2/data/several', checkAccess, analyticsHandler, api.file.getSeveral, errorHandler); 1279 /**1280 * @api {post} /v2/data/delete Delete data1281 * @apiName delete1282 * @apiGroup File1283 * @apiUse token1284 * @apiParam {String} file_id File id1285 * @apiSuccess {json} status Upload Status JSON1286 * @apiSuccessExample {json} Success-Response:1287 * {1288 * "success": true,1289 * "err": {}1290 * }1291 * @apiError {json} Bad_request file_id does not exist in request body (400)1292 * @apiErrorExample {json} Error-Response:1293 * Error 400: Bad request1294 * {1295 * "error": {1296 * "message": "Missing information. Check out https://github.com/mapic/mapic for details on the API.",1297 * "code": "400",1298 * "errors": {1299 * "missingRequiredFields": ['file_id']1300 * }1301 * }1302 * }1303 * @apiError {json} Not_found database_name or table_name does not exist in file.data.postgis or file_id doesn't exist in file.data.raster (404)1304 * @apiErrorExample {json} Error-Response:1305 * Error 404: Not found1306 * {1307 * "error": {1308 * "message": "Missing information. Check out https://github.com/mapic/mapic for details on the API.",1309 * "code": "404"1310 * }1311 * }1312 * @apiError {json} Internal_server_error Problems with drop table (500)1313 * @apiErrorExample {json} Error-Response:1314 * Error 500: Internal server error1315 * {1316 * "error": {1317 * "message": "Can't drop table tableName",1318 * "code": "500"1319 * }1320 * }1321 * @apiError {json} Not_found If file type is postgis and file with file.data.posgis.table_name id doesn't exist(404)1322 * @apiErrorExample {json} Error-Response:1323 * Error 404: Not found1324 * {1325 * "error": {1326 * "message": "No such file.",1327 * "code": "404"1328 * }1329 * }1330 */1331 // =====================================1332 // DELETE DATA =========================1333 // =====================================1334 // change to /api/data/delete1335 app.post('/v2/data/delete', checkAccess, analyticsHandler, api.file.deleteFile, errorHandler);1336 app.post('/v2/data/external', checkAccess, analyticsHandler, api.layer.getExternal, errorHandler); // todo: layer/layers !! make all same...1337 /**1338 * @api {post} /v2/projects/data Add file to the project1339 * @apiName addToTheProject1340 * @apiGroup File1341 * @apiUse token1342 * @apiParam {String} file_id File id1343 * @apiParam {String} project_id Project id1344 * @apiSuccess {json} status Upload Status JSON1345 * @apiSuccessExample {json} Success-Response:1346 *{1347 * _id: '56a76e07b6aa58e535c88d22',1348 * lastUpdated: '2016-01-26T13:00:55.159Z',1349 * created: '2016-01-26T13:00:55.018Z',1350 * createdByUsername: 'relatedProjectCreatedByUsername',1351 * createdByName: 'relatedProjectCreatedByName',1352 * createdBy: 'relatedProjectCreatedBy',1353 * uuid: 'relatedProjectInfo',1354 * layers: ['56a76e07b6aa58e535c88d23'],1355 * files: ['56a76e07b6aa58e535c88d21'],1356 * roles: [],1357 * access: {1358 * options: {1359 * isPublic: false,1360 * download: false,1361 * share: true1362 * },1363 * edit: [],1364 * read: ['test-user-uuid']1365 * },1366 * categories: [],1367 * keywords: [],1368 * description: 'Description',1369 * slug: 'projectslug',1370 * name: 'relatedProjectName'1371 * etc...1372 *}1373 * @apiError {json} Bad_request file_id or project_id does not exist in request body (400)1374 * @apiErrorExample {json} Error-Response:1375 * Error 400: Bad request1376 * {1377 * "error": {1378 * "message": "Missing information. Check out https://github.com/mapic/mapic for details on the API.",1379 * "code": "400",1380 * "errors": {1381 * "missingRequiredFields": ['file_id', 'project_id']1382 * }1383 * }1384 * }1385 * @apiError {json} Not_found File with specific id not found(404)1386 * @apiErrorExample {json} Error-Response:1387 * Error 404: Not found1388 * {1389 * "error": {1390 * "message": "No such file",1391 * "code": "404"1392 * }1393 * }1394 * @apiError {json} Not_found Project with specific id not found(404)1395 * @apiErrorExample {json} Error-Response:1396 * Error 404: Not found1397 * {1398 * "error": {1399 * "message": "No such project",1400 * "code": "404"1401 * }1402 * }1403 */1404 // =====================================1405 // ADD/LINK FILE TO NEW PROJECT ========1406 // =====================================1407 // change to /api/project/addData1408 app.post('/v2/projects/data', checkAccess, analyticsHandler, api.file.addFileToProject, errorHandler);1409 /**1410 * @api {post} /v2/layers/delete Delete layer1411 * @apiName delete1412 * @apiGroup Layer1413 * @apiUse token1414 * @apiParam {String} layer_id Layer id1415 * @apiParam {String} project__id Project id 1416 * @apiSuccess {json} status Upload Status JSON1417 * @apiSuccessExample {json} Success-Response:1418 * {1419 * "success": true,1420 * "err": {}1421 * }1422 * @apiError {json} Bad_request layer_id or project_id does not exist in request body (400)1423 * @apiErrorExample {json} Error-Response:1424 * Error 400: Bad request1425 * {1426 * "error": {1427 * "message": "Missing information. Check out https://github.com/mapic/mapic for details on the API.",1428 * "code": "400",1429 * "errors": {1430 * "missingRequiredFields": ['layer_id', 'project_id']1431 * }1432 * }1433 * }1434 * @apiError {json} Not_found Layer with specific id not found(404)1435 * @apiErrorExample {json} Error-Response:1436 * Error 404: Not found1437 * {1438 * "error": {1439 * "message": "No such layers",1440 * "code": "404"1441 * }1442 * }1443 * @apiError {json} Not_found Project with specific id not found(404)1444 * @apiErrorExample {json} Error-Response:1445 * Error 404: Not found1446 * {1447 * "error": {1448 * "message": "No such project.",1449 * "code": "404"1450 * }1451 * }1452 */1453 // =====================================1454 // DELETE LAYER(S) =====================1455 // =====================================1456 // change to /api/layer/delete (layer, not layers)1457 app.post('/v2/layers/delete', checkAccess, analyticsHandler, api.layer.deleteLayer, errorHandler);1458 /**1459 * @api {get} /v2/projects/layers Get layers related with project1460 * @apiName get layers by project id1461 * @apiGroup Layer1462 * @apiUse token1463 * @apiParam {String} project Project uuid1464 * @apiSuccess {Array} layers Array of layers related with project1465 * @apiSuccessExample {json} Success-Response:1466 *[{1467 * data: [Object],1468 * __v: 0,1469 * uuid: 'relatedLayerUuid',1470 * title: 'relatedLayerTitle',1471 * description: 'relatedLayerDescription',1472 * created: Mon Jan 25 2016 11: 37: 44 GMT + 0000(UTC),1473 * lastUpdated: Mon Jan 25 2016 11: 37: 44 GMT + 0000(UTC),1474 * _id: 56 a60908fdce40a15eca67731475 *}, and etc]1476 * @apiError {json} Bad_request project does not exist in request body (400)1477 * @apiErrorExample {json} Error-Response:1478 * Error 400: Bad request1479 * {1480 * "error": {1481 * "message": "Missing information. Check out https://github.com/mapic/mapic for details on the API.",1482 * "code": "400",1483 * "errors": {1484 * "missingRequiredFields": ['project']1485 * }1486 * }1487 * }1488 */1489 // =====================================1490 // LAYERS ==============================1491 // =====================================1492 // change to /api/layer/get 1493 // app.post('/api/layers', checkAccess, api.layer.get, errorHandler); // todo: layer/layers !! make all same...1494 app.get('/v2/projects/layers', checkAccess, analyticsHandler, api.layer.get, errorHandler); // todo: layer/layers !! make all same...1495 // todo: /v2/projects/layers GET request1496 /**1497 * @api {post} /v2/layers/create Create layer1498 * @apiName create1499 * @apiGroup Layer1500 * @apiUse token1501 * @apiParam {String} [title] Title of new layer1502 * @apiParam {String} [description] Description of new layer1503 * @apiParam {String} [legend] Legend of new legend1504 * @apiParam {String} [file] File of new layer1505 * @apiParam {String} [metadata] Metadata of new layer1506 * @apiParam {Object} [data] Data of new layer1507 * @apiParam {String} [style] Style of new layer1508 * @apiSuccess {JSON} Layer New layer object1509 * @apiSuccessExample {json} Success-Response:1510 * {1511 * __v: 0,1512 * lastUpdated: '2016-01-20T10:55:30.983Z',1513 * created: '2016-01-20T10:55:30.983Z',1514 * legend: '',1515 * description: 'new layer description',1516 * title: 'new layer title',1517 * uuid: 'layer-ae4fc38c-58f0-4468-81e7-7330d226dc24',1518 * _id: '569f67a2ebb7233b667d8a02'1519 * }1520 */1521 // =====================================1522 // CREATE NEW LAYER ====================1523 // =====================================1524 // change to /api/layer/create 1525 app.post('/v2/layers/create', checkAccess, analyticsHandler, api.layer.create, errorHandler);1526 /**1527 * @api {post} /v2/layers/create/default Create default layer1528 * @apiName create default1529 * @apiGroup Layer1530 * @apiUse token1531 * @apiSuccess {String} pile1532 * @apiSuccess {String} wu1533 * @apiSuccessExample {json} Success-Response:1534 * {1535 * pile : 'ok', 1536 * wu : 'ok'1537 * }1538 */1539 // todo: refactor to /v2/layers/create with default flag1540 // =====================================1541 // CREATE NEW DEFAULT LAYER ============1542 // =====================================1543 // app.post('/api/layers/default', checkAccess, api.layer.createDefaultLayers, errorHandler);1544 app.post('/v2/layers/create/default', checkAccess, analyticsHandler, api.layer.createDefaultLayers, errorHandler);1545 /**1546 * @api {post} /v2/layers/update Update layer1547 * @apiName update1548 * @apiGroup Layer1549 * @apiUse token1550 * @apiParam {String} layer uuid of updated layer1551 * @apiParam {String} [title] New title of updated layer1552 * @apiParam {String} [description] New description of updated layer1553 * @apiParam {String} [satellite_position] New satellite_position of updated layer1554 * @apiParam {String} [copyright] New copyright of updated layer1555 * @apiParam {String} [tooltip] New tooltip of updated layer1556 * @apiParam {String} [style] New style of updated layer1557 * @apiParam {String} [filter] New filter of updated layer1558 * @apiParam {String} [legends] New legends of updated layer1559 * @apiParam {String} [opacity] New opacity of updated layer1560 * @apiParam {Number} [zIndex] New zIndex of updated layer1561 * @apiParam {Object} [data] New data of updated layer1562 * @apiSuccess {String} response Update info 1563 * @apiSuccessExample {String} Success-Response:1564 * {1565 * updated: ['satellite_position',1566 * 'description',1567 * 'copyright',1568 * 'title',1569 * 'tooltip',1570 * 'style',1571 * 'filter',1572 * 'legends',1573 * 'opacity',1574 * 'zIndex',1575 * 'data'1576 * ],1577 * layer: {1578 * _id: '56c5b2570bfe2137063a6c44',1579 * lastUpdated: '2016-02-18T12:00:23.471Z',1580 * created: '2016-02-18T12:00:23.471Z',1581 * description: 'update mocha test layer description',1582 * title: 'update mocha test layer title',1583 * uuid: 'new mocha test layer uuid',1584 * __v: 0,1585 * satellite_position: 'update mocha test layer satellite_position',1586 * copyright: 'update mocha test layer copyright',1587 * tooltip: 'update mocha test layer tooltip',1588 * style: 'update mocha test layer style',1589 * filter: 'update mocha test layer filter',1590 * legends: 'update mocha test layer legends',1591 * opacity: 'update mocha test layer opacity',1592 * zIndex: 4,1593 * data: {1594 * geojson: 'update mocha test layer geojson',1595 * topojson: 'update mocha test layer topojson',1596 * cartoid: 'update mocha test layer cartoid',1597 * raster: 'update mocha test layer raster',1598 * rastertile: 'update mocha test layer rastertile',1599 * vectortile: 'update mocha test layer vectortile',1600 * mapbox: 'update mocha test layer mapbox',1601 * cartodb: 'update mocha test layer cartodb',1602 * osm: 'update mocha test layer osm',1603 * norkart: 'update mocha test layer norkart',1604 * google: 'update mocha test layer google',1605 * postgis: [Object]1606 * }1607 * }1608 * }1609 * @apiError {json} Bad_request layer does not exist in request body (400)1610 * @apiErrorExample {json} Error-Response:1611 * Error 400: Bad request1612 * {1613 * "error": {1614 * "message": "Missing information. Check out https://github.com/mapic/mapic for details on the API.",1615 * "code": "400",1616 * "errors": {1617 * "missingRequiredFields": ['layer']1618 * }1619 * }1620 * }1621 * @apiError {json} Not_found If layer doesn't exist(404)1622 * @apiErrorExample {json} Error-Response:1623 * Error 404: Not found1624 * {1625 * "error": {1626 * "message": "No such layer.",1627 * "code": "404"1628 * }1629 * }1630 */1631 // =====================================1632 // UPDATE LAYERS =======================1633 // =====================================1634 app.post('/v2/layers/update', checkAccess, analyticsHandler, api.layer.update, errorHandler);1635 // // =====================================1636 // // UPDATE LAYERS =======================1637 // // =====================================1638 // app.post('/v2/layers/update/cube', checkAccess, analyticsHandler, api.layer.updateCube, errorHandler);1639 /**1640 * @api {post} /v2/layers/meta Reload meta1641 * @apiName reload meta1642 * @apiGroup Layer1643 * @apiUse token1644 * @apiParam {String} file_id File uuid1645 * @apiParam {String} layer_id Layer uuid1646 * @apiSuccess {String} response Update info 1647 * @apiSuccessExample {String} Success-Response:1648 * {1649 * error : err,1650 * meta : meta1651 * }1652 * @apiError {json} Bad_request No meta (400)1653 * @apiErrorExample {json} Error-Response:1654 * Error 400: Bad request1655 * {1656 * "error": 'No meta.'1657 * }1658 * @apiError {json} Bad_request layer_id or file_id do not exist in request body (400)1659 * @apiErrorExample {json} Error-Response:1660 * Error 400: Bad request1661 * {1662 * "error": {1663 * "message": "Missing information. Check out https://github.com/mapic/mapic for details on the API.",1664 * "code": "400",1665 * "errors": {1666 * "missingRequiredFields": ['layer_id', 'file_id']1667 * }1668 * }1669 * }1670 * @apiError {json} Not_found If file doesn't exist(404)1671 * @apiErrorExample {json} Error-Response:1672 * Error 404: Not found1673 * {1674 * "error": {1675 * "message": "No such file.",1676 * "code": "404"1677 * }1678 * }1679 */1680 // =====================================1681 // RELOAD LAYER METADATA ===============1682 // =====================================1683 // change to /api/layer/reloadMeta (camelcase) 1684 app.post('/v2/layers/meta', checkAccess, analyticsHandler, api.layer.reloadMeta, errorHandler);1685 /**1686 * @api {post} /v2/layers/carto/ Set carto css1687 * @apiName set carto css1688 * @apiGroup Layer1689 * @apiUse token1690 * @apiParam {String} fileUuid File uuid1691 * @apiParam {String} css New carto css1692 * @apiParam {String} cartoid Id of mss file1693 * @apiParam {String} layerUuid Layer uuid1694 * @apiSuccess {Boolean} ok 1695 * @apiSuccess {String} cartoid Carto css id1696 * @apiSuccess {Object} error Error object1697 * @apiError {json} Bad_request If mss file doesn't exist(400)1698 * @apiErrorExample {json} Error-Response:1699 * Error 400: Bad request1700 * {1701 * "error": "ENOENT, open '/data/cartocss/test.mss'"1702 * }1703 * @apiError {json} Not_found If layer doesn't exist(400)1704 * @apiErrorExample {json} Error-Response:1705 * Error 400: Bad request1706 * {1707 * "error": "No layer."1708 * }1709 */1710 1711 // =====================================1712 // SET CARTOCSS ========================1713 // =====================================1714 // change to /api/layer/carto/set 1715 app.post('/v2/layers/carto', checkAccess, analyticsHandler, api.layer.setCartoCSS, errorHandler);1716 /**1717 * @api {get} /v2/layers/carto/ Get carto css1718 * @apiName get carto css1719 * @apiGroup Layer1720 * @apiUse token1721 * @apiParam {String} cartoid Id of mss file1722 * @apiSuccess {String} cartocss Carto css string1723 * @apiError {json} Bad_request If mss file doesn't exist(400)1724 * @apiErrorExample {json} Error-Response:1725 * Error 400: Bad request1726 * {1727 * "error": "ENOENT, open '/data/cartocss/test.mss'"1728 * }1729 */1730 // =====================================1731 // GET CARTOCSS ========================1732 // =====================================1733 // change to /api/layer/carto/get 1734 app.get('/v2/layers/carto', checkAccess, analyticsHandler, api.layer.getCartoCSS, errorHandler);1735 /**1736 * @api {post} /v2/users/update Update user1737 * @apiName update1738 * @apiGroup User1739 * @apiUse token1740 * @apiParam {String} uuid Uuid of user1741 * @apiParam {String} [firstname] First name1742 * @apiParam {String} [lastname] Last name1743 * @apiParam {String} [company] Company1744 * @apiParam {String} [position] Position in company1745 * @apiSuccess {Array} updated Array of updated fields1746 * @apiSuccess {Object} user Updated user1747 * @apiSuccessExample {json} Success-Response:1748 * {1749 * "updated": ['phone', 'company'],1750 * "user": {1751 * lastUpdated: '2016-01-19T12:49:49.076Z',1752 * created: '2016-01-19T12:49:48.943Z',1753 * ... etc1754 * }1755 * }1756 * @apiError {json} Bad_request uuid does not exist in request body (400)1757 * @apiErrorExample {json} Error-Response:1758 * Error 400: Bad request1759 * {1760 * "error": {1761 * "message": "Missing information. Check out https://github.com/mapic/mapic for details on the API.",1762 * "code": "400",1763 * "errors": {1764 * "missingRequiredFields": ['uuid']1765 * }1766 * }1767 * }1768 * @apiError {json} Bad_request uuid does not exist in request body (400)1769 * @apiErrorExample {json} Error-Response:1770 * Error 400: Bad request1771 * {1772 * "error": {1773 * "message": "No access.",1774 * "code": "400"1775 * }1776 * }1777 * @apiError {json} Not_found If user doesn't exist(404)1778 * @apiErrorExample {json} Error-Response:1779 * Error 404: Not found1780 * {1781 * "error": {1782 * "message": "No such user.",1783 * "code": "404"1784 * }1785 * }1786 */1787 // =====================================1788 // UPDATE USER INFORMATION ============1789 // =====================================1790 app.post('/v2/users/update', checkAccess, analyticsHandler, api.user.update, errorHandler);1791 /**1792 * @api {get} /v2/users/info Get info on authenticated user1793 * @apiName info1794 * @apiGroup User1795 * @apiUse token1796 * @apiSuccess {Object} user User1797 * @apiSuccessExample {json} Success-Response:1798 * {1799 * "user": {1800 * lastUpdated: '2016-01-19T12:49:49.076Z',1801 * created: '2016-01-19T12:49:48.943Z',1802 * ... etc1803 * }1804 * }1805 */1806 // =====================================1807 // UPDATE USER INFORMATION ============1808 // =====================================1809 app.get('/v2/users/info', checkAccess, analyticsHandler, api.user.info, errorHandler);1810 // old route, keeping for backwards compatibility1811 app.post('/api/user/info', checkAccess, analyticsHandler, api.user.info, errorHandler);1812 // =====================================1813 // CREATE NEW USER =====================1814 // =====================================1815 /**1816 * @api {post} /v2/users/create Create new user1817 * @apiName info1818 * @apiGroup User1819 * @apiUse token1820 * @apiParam {String} username Unique username1821 * @apiParam {String} firstname First name1822 * @apiParam {String} lastname Last name1823 * @apiParam {String} [company] Company1824 * @apiParam {String} [position] Position in company1825 * @apiParam {String} email Email1826 * @apiParam {String} password Password1827 * @apiSuccess {json} user User1828 * @apiSuccessExample {json} Success-Response:1829 * {1830 * "user": {1831 * lastUpdated: '2016-01-19T12:49:49.076Z',1832 * created: '2016-01-19T12:49:48.943Z',1833 * ... etc.1834 * }1835 * }1836 * @apiError {json} Bad_request username or firstname or lastname or email or password do not exist in request body (400)1837 * @apiErrorExample {json} Error-Response:1838 * Error 400: Bad request1839 * {1840 * "error": {1841 * "message": "Missing information. Check out https://github.com/mapic/mapic for details on the API.",1842 * "code": "400",1843 * "errors": {1844 * "missingRequiredFields": ["username", "firstname", "lastname", "email", "password"]1845 * }1846 * }1847 * }1848 */1849 app.post('/v2/users/create', analyticsHandler, api.user.create, errorHandler);1850 // TODO this endpoint does not exist1851 // =====================================1852 // DELETE USER =========================1853 // =====================================1854 app.post('/v2/users/delete', checkAccess, api.user.deleteUser, errorHandler);1855 app.post('/v2/users/promote', checkAccess, api.user.promote, errorHandler);1856 app.post('/v2/layers/getLayer', checkAccess, api.layer.getLayer, errorHandler);1857 /**1858 * @apiIgnore1859 * @api {post} /v2/users/email/unique Is unique email1860 * @apiName unique email1861 * @apiGroup User1862 * @apiUse token1863 * @apiParam {String} email Email which should be check1864 * @apiSuccess {Boolean} unique True if email is unique1865 * @apiSuccessExample {json} Success-Response:1866 * {1867 * "unique": true1868 * }1869 * @apiError {json} Bad_request Email does not exist in request body (400)1870 * @apiErrorExample {json} Error-Response:1871 * Error 400: Bad request1872 * {1873 * "error": {1874 * "message": "Missing information. Check out https://github.com/mapic/mapic for details on the API.",1875 * "code": "400",1876 * "errors": {1877 * "missingRequiredFields": ['email']1878 * }1879 * }1880 * }1881 */1882 // =====================================1883 // CHECK UNIQUE USER/EMAIL =============1884 // =====================================1885 app.post('/v2/users/email/unique', analyticsHandler, api.user.checkUniqueEmail, errorHandler);1886 /**1887 * @apiIgnore1888 * @api {post} /v2/users/username/unique Is unique email1889 * @apiName unique username1890 * @apiGroup User1891 * @apiUse token1892 * @apiParam {String} username Username which should be check1893 * @apiSuccess {Boolean} unique True if username is unique1894 * @apiSuccessExample {json} Success-Response:1895 * {1896 * "unique": true1897 * }1898 * @apiError {json} Bad_request Username does not exist in request body (400)1899 * @apiErrorExample {json} Error-Response:1900 * Error 400: Bad request1901 * {1902 * "error": {1903 * "message": "Missing information. Check out https://github.com/mapic/mapic for details on the API.",1904 * "code": "400",1905 * "errors": {1906 * "missingRequiredFields": ['username']1907 * }1908 * }1909 * }1910 */1911 // =====================================1912 // CHECK UNIQUE USER/EMAIL =============1913 // =====================================1914 app.post('/v2/users/username/unique', analyticsHandler, api.user.checkUniqueUsername, errorHandler);1915 /**1916 * @api {post} /v2/users/invite Send invite mail1917 * @apiName Send invite mail1918 * @apiGroup User1919 * @apiUse token1920 * @apiParam {Array} emails Array of emails1921 * @apiParam {String} [customMessage] Custom message1922 * @apiParam {Object} access Access object 1923 * @apiSuccess {Object} error error object1924 * @apiSuccessExample {json} Success-Response:1925 * {1926 * "error": null1927 * }1928 * @apiError {json} Bad_request Emails or customMessage or access do not exist in request body (400)1929 * @apiErrorExample {json} Error-Response:1930 * Error 400: Bad request1931 * {1932 * "error": {1933 * "message": "Missing information. Check out https://github.com/mapic/mapic for details on the API.",1934 * "code": "400",1935 * "errors": {1936 * "missingRequiredFields": ['emails', 'customMessage', 'access']1937 * }1938 * }1939 * }1940 */1941 // =====================================1942 // SEND INVITE MAIL ====================1943 // =====================================1944 // rename to /api/user/invite/email1945 // app.post('/api/user/invite', checkAccess, api.user.invite, errorHandler);1946 app.post('/v2/users/invite', checkAccess, analyticsHandler, api.user.invite, errorHandler);1947 /**1948 * @api {post} /v2/users/invite/accept Accept invite1949 * @apiName Accept invite1950 * @apiGroup User1951 * @apiUse token1952 * @apiParam {String} invite_token Invite token (for example 55mRbPA)1953 * @apiSuccess {Object} invite Accepted invite1954 * @apiSuccessExample {json} Success-Response:1955 * {1956 * "email": false,1957 * "access": {1958 * "edit": [1959 * "project-ef990c38-f16c-478e-9ed1-65ed2808b070"1960 * ],1961 * "read": [1962 * "project-65f99b5c-a645-4f3a-8905-9fad85c59c40",1963 * "project-f7a9dd0b-4113-44a0-8e2d-e0d752f1cc04",1964 * "project-c72c3d83-ff96-4483-8f39-f942c0187108"1965 * ]1966 * },1967 * "token": "L9Jfxks",1968 * "invited_by": "user-805dc4a1-2535-41f3-9a1b-af32ad134692",1969 * "timestamp": 1455569798000,1970 * "type": "link"1971 * }1972 * @apiError {json} Bad_request Invite_token does not exist in request body (400)1973 * @apiErrorExample {json} Error-Response:1974 * Error 400: Bad request1975 * {1976 * "error": {1977 * "message": "Missing information. Check out https://github.com/mapic/mapic for details on the API.",1978 * "code": "400",1979 * "errors": {1980 * "missingRequiredFields": ['invite_token']1981 * }1982 * }1983 * }1984 * @apiError {json} Not_found Some of project does not exist (404)1985 * @apiErrorExample {json} Error-Response:1986 * Error 404: Not found1987 * {1988 * "error": {1989 * "message": "No such project.",1990 * "code": "404"1991 * }1992 * }1993 */1994 // =====================================1995 // PROCESS INVITE FOR USER =============1996 // =====================================1997 // rename to /api/user/invite/email1998 // app.post('/api/user/invite/accept', checkAccess, api.user.acceptInvite, errorHandler);1999 app.post('/v2/users/invite/accept', checkAccess, analyticsHandler, api.user.acceptInvite, errorHandler);2000 /**2001 * @api {post} /v2/users/contacts/request Request contact2002 * @apiName Request contact2003 * @apiGroup User2004 * @apiUse token2005 * @apiParam {String} contact User id2006 * @apiSuccess {Object} error error object2007 * @apiSuccessExample {json} Success-Response:2008 * {2009 * "error": null2010 * }2011 * @apiError {json} Bad_request Contact does not exist in request body (400)2012 * @apiErrorExample {json} Error-Response:2013 * Error 400: Bad request2014 * {2015 * "error": {2016 * "message": "Missing information. Check out https://github.com/mapic/mapic for details on the API.",2017 * "code": "400",2018 * "errors": {2019 * "missingRequiredFields": ['contact']2020 * }2021 * }2022 * }2023 * @apiError {json} Bad_request user does not exist in request body (404)2024 * @apiErrorExample {json} Error-Response:2025 * Error 404: Not found2026 * {2027 * "error": {2028 * "message": "No such user.",2029 * "code": "404"2030 * }2031 * }2032 */2033 // =====================================2034 // REQUEST CONTACT =====================2035 // =====================================2036 app.post('/v2/users/contacts/request', checkAccess, analyticsHandler, api.user.requestContact, errorHandler);2037 // =====================================2038 // REQUEST CONTACT =====================2039 // =====================================2040 // change to /api/user/acceptContact/*2041 app.get('/api/user/acceptContactRequest/*', analyticsHandler, api.user.acceptContactRequest, errorHandler); // todo: POST?2042 /**2043 * @api {post} /v2/users/invite/projects Invite user to projects2044 * @apiName Invite user to projects2045 * @apiGroup User2046 * @apiUse token2047 * @apiParam {String} user User id2048 * @apiParam {Array} edit Array of project ids which user will be able to edit 2049 * @apiParam {String} read Array of project ids which user will be able to read2050 * @apiSuccess {Object} error error object2051 * @apiSuccess {array} projects error object2052 * @apiSuccessExample {json} Success-Response:2053 * {2054 * error: null,2055 * projects: [{2056 * project: 'uuid-mocha-test-project',2057 * access: {2058 * read: ['second_test-user-uuid'],2059 * edit: [],2060 * options: {2061 * share: true,2062 * download: false,2063 * isPublic: false2064 * }2065 * }2066 * }]2067 * }2068 * @apiError {json} Bad_request User, edits and reads do not exist in request body (400)2069 * @apiErrorExample {json} Error-Response:2070 * Error 400: Bad request2071 * {2072 * "error": {2073 * "message": "Missing information. Check out https://github.com/mapic/mapic for details on the API.",2074 * "code": "400",2075 * "errors": {2076 * "missingRequiredFields": ['user']2077 * }2078 * }2079 * }2080 */2081 // =====================================2082 // INVITE TO PROJECTS ==================2083 // =====================================2084 // todo: see if this can be removed (replaced by /api/user/invite?)2085 app.post('/v2/users/invite/projects', checkAccess, analyticsHandler, api.user.inviteToProjects, errorHandler);2086 /**2087 * @api {get} /v2/users/invite/link Invite user to projects2088 * @apiName Invite user to projects2089 * @apiGroup User2090 * @apiUse token2091 * @apiParam {Object} access Access object2092 * @apiSuccess {String} link Invite link2093 * @apiSuccessExample {json} Success-Response:2094 * https://maps.mapic.io/invite/7Tf7Bc82095 * @apiError {json} Bad_request access does not exist in request body (400)2096 * @apiErrorExample {json} Error-Response:2097 * Error 400: Bad request2098 * {2099 * "error": {2100 * "message": "Missing information. Check out https://github.com/mapic/mapic for details on the API.",2101 * "code": "400",2102 * "errors": {2103 * "missingRequiredFields": ['access']2104 * }2105 * }2106 * }2107 */2108 // =====================================2109 // GENERATE ACCESS LINK ================2110 // =====================================2111 app.get('/v2/users/invite/link', checkAccess, analyticsHandler, api.user.getInviteLink, errorHandler);2112 // =====================================2113 // CHECK RESET PASSWORD TOKEN ==========2114 // =====================================2115 app.post('/reset/checktoken', analyticsHandler, api.auth.checkResetToken, errorHandler);2116 /**2117 * @api {post} /v2/users/password/reset Send reset password mail2118 * @apiName send reset password mail2119 * @apiGroup User2120 * @apiParam {String} email User's email2121 * @apiSuccess {String} text Please check your email for password reset link.2122 * @apiError {json} Bad_request Email does not exist in request body (400)2123 * @apiErrorExample {json} Error-Response:2124 * Error 400: Bad request2125 * {2126 * "error": {2127 * "message": "Missing information. Check out https://github.com/mapic/mapic for details on the API.",2128 * "code": "400",2129 * "errors": {2130 * "missingRequiredFields": ['email']2131 * }2132 * }2133 * }2134 * @apiError {json} Not_found If user with specific email doesn't exist(404)2135 * @apiErrorExample {json} Error-Response:2136 * Error 404: User not found2137 * {2138 * "error": {2139 * "message": "No such user.",2140 * "code": "404"2141 * }2142 * }2143 */2144 // =====================================2145 // SEND RESET PASSWORD MAIL ============2146 // =====================================2147 app.post('/v2/users/password/reset', analyticsHandler, api.auth.requestPasswordReset, errorHandler);2148 // =====================================2149 // RESET PASSWORD ======================2150 // =====================================2151 // change to /api/... 2152 app.get('/reset', analyticsHandler, api.auth.serveResetPage, errorHandler);2153 /**2154 * @api {post} /v2/users/password Reset password2155 * @apiName reset password2156 * @apiGroup User2157 * @apiParam {String} password New password2158 * @apiParam {String} token Access token2159 * @apiSuccess {String} text Moved Temporarily. Redirecting to /2160 * @apiError {json} Bad_request password or token do not exist in request body (400)2161 * @apiErrorExample {json} Error-Response:2162 * Error 400: Bad request2163 * {2164 * "error": {2165 * "message": "Missing information. Check out https://github.com/mapic/mapic for details on the API.",2166 * "code": "400",2167 * "errors": {2168 * "missingRequiredFields": ['token', 'password']2169 * }2170 * }2171 * }2172 * @apiError {json} Not_found If file doesn't upload(404)2173 * @apiErrorExample {json} Error-Response:2174 * Error 401: Invalid token2175 * {2176 * "error": {2177 * "message": "Invalid access token.",2178 * "code": "401"2179 * }2180 * }2181 */2182 // =====================================2183 // CREATE PASSWORD =====================2184 // ===================================== 2185 app.post('/v2/users/password', analyticsHandler, api.auth.resetPassword, errorHandler);2186 // =====================================2187 // ANALYTICS ===================2188 // =====================================2189 app.get('/v2/static/getCustomData', checkAccess, analyticsHandler, api.file.getCustomData, errorHandler);2190 // ===================================== // todo: rename route to /api/config/client.js2191 // SERVER CLIENT CONFIG ================2192 // =====================================2193 // change to /api/... 2194 app.get('/clientConfig.js', analyticsHandler, function (req, res) {2195 var configString = 'var systemapicConfigOptions = ' + JSON.stringify(api.clientConfig);2196 res.setHeader("content-type", "application/javascript");2197 res.send(configString);2198 }, errorHandler);2199 // =====================================2200 // DEBUG: PHANTOMJS FEEDBACK ===========2201 // ===================================== 2202 // app.post('/api/debug/phantom', checkAccess, function (req, res) {2203 // res.end();2204 // });2205 // =====================================2206 // PRIVACY POLICY ======================2207 // =====================================2208 // change to /v2/docs/privacy-policy2209 app.get('/privacy-policy', analyticsHandler, function(req, res) {2210 // api.portal.login(req, res);2211 res.render('../../views/privacy.ejs');2212 }, errorHandler);2213 // =====================================2214 // LOGOUT ==============================2215 // =====================================2216 app.get('/logout', analyticsHandler, api.portal.logout, errorHandler);2217 // =====================================2218 // INVITE ==============================2219 // =====================================2220 app.get('/invite/*', analyticsHandler, api.portal.invite, errorHandler);2221 // =====================================2222 // FORGOT PASSWORD =====================2223 // =====================================2224 app.post('/api/forgot', analyticsHandler, api.auth.forgotPassword, errorHandler);2225 // =====================================2226 // FORGOT PASSWORD =====================2227 // =====================================2228 app.get('/forgot', analyticsHandler, function (req, res) {2229 res.render('../../views/forgot.ejs', {});2230 }, errorHandler);2231 // =====================================2232 // DEBUG =====================2233 // =====================================2234 // app.get('/api/debug', analyticsHandler, function (req, res) {2235 // res.render('../../views/debug/debug.ejs', {});2236 // }, errorHandler);2237 // =====================================2238 // WILDCARD PATHS ====================== 2239 // =====================================2240 app.get('*', analyticsHandler, function (req, res) {2241 api.portal.wildcard(req, res);2242 }, errorHandler);2243 // // helper function : if is logged in2244 // function isLoggedIn(req, res, next) {2245 // if (req.isAuthenticated()) return next();2246 // res.redirect('/');2247 // }2248 ...

Full Screen

Full Screen

routes12.js

Source:routes12.js Github

copy

Full Screen

1var adminHome = require('../app/controllers/admin/home');2var adminCategory = require('../app/controllers/admin/category');3var adminSubCategory = require('../app/controllers/admin/subcategory');4var adminuser = require('../app/controllers/admin/userList');5var frontHome = require('../app/controllers/front/home');6var User = require('../app/controllers/front/user');7var login = require('../app/controllers/front/login');8var booking = require('../app/controllers/front/booking');9var explore = require('../app/controllers/front/explore');10var payment = require('../app/controllers/front/payment');11var frontService = require('../app/controllers/front/service');12var fregister = require('../app/controllers/admin/firebaseregister');13var stripe = require('../app/controllers/front/stripe');14var staff = require('../app/controllers/front/staff');1516//Api //1718var artist = require('../app/controllers/api/artist');19var user = require('../app/controllers/api/user');20var appUser = require('../app/controllers/api/user');21var service = require('../app/controllers/api/service_controller');22var authtokenCheck = require('../app/controllers/api/validateRequest');2324//Api//25//you can include all your controllers2627module.exports = function (app, passport) {2829 app.get('/admin/login', adminHome.login);30 app.get('/signup', adminHome.signup);31 app.get('/fregister', fregister.fregister);32 app.get('/logout', adminHome.logout);33 app.get('/',login.profileCheck,booking.locationGet,booking.categoryGet,booking.searchbooking); 34 app.get('/home',frontHome.loggedIn,login.profileCheck,booking.locationGet,booking.categoryGet,booking.searchbooking);3536 app.get('/adminDashboard', adminHome.loggedIn, adminHome.categoryCount, adminHome.subcategoryCount, adminHome.userCount, adminHome.artistCount, adminHome.home);//home37 app.get('/adminProfile', adminHome.loggedIn, adminHome.profile);//admin profile38394041 app.post('/signup', passport.authenticate('local-signup', {42 successRedirect: '/adminDashboard', // redirect to the secure profile section43 failureRedirect: '/signup', // redirect back to the signup page if there is an error44 failureFlash: true // allow flash messages45 }));46 // process the login form4748 app.post('/admin/login', passport.authenticate('local-login', {49 50 successRedirect: '/adminDashboard', // redirect to the secure profile section51 failureRedirect: '/admin/login', // redirect back to the signup page if there is an error52 failureFlash: true // allow flash messages5354 }));5556 57 /* Category module start*/5859 app.get('/addCategory',adminCategory.loggedIn, adminCategory.addCategory);60 app.post('/createCategory', adminCategory.loggedIn , adminCategory.insertCategory);61 app.get('/listCategory',adminCategory.loggedIn, adminCategory.listCategory);62 app.get('/categoryList', adminCategory.categoryList);63 app.get('/categoryEdit/:categoryId',adminCategory.loggedIn, adminCategory.edit);64 app.get('/categoryStatus/:categoryId/:status',adminCategory.loggedIn, adminCategory.categoryStatus);65 app.post('/updateCategory', adminCategory.loggedIn , adminCategory.updateCategory);66 app.get('/categoryDelete/:categoryId',adminCategory.loggedIn, adminCategory.categoryDelete);6768 /* Category module end*/697071 /* Sub Category module start*/7273 app.get('/addSubCategory',adminCategory.loggedIn, adminSubCategory.addSubCategory);74 app.post('/createSubCategory', adminCategory.loggedIn , adminSubCategory.insertSubCategory);75 app.get('/listSubCategory',adminCategory.loggedIn, adminSubCategory.listsubCategory);76 app.get('/subcategoryList', adminSubCategory.subcategoryList);77 app.get('/categorySubEdit/:categoryId',adminCategory.loggedIn, adminSubCategory.edit);78 app.get('/subServicesStatus/:categoryId/:status',adminCategory.loggedIn, adminSubCategory.subServicesStatus);79 app.post('/updateSubCategory', adminCategory.loggedIn , adminSubCategory.updateSubCategory);80 app.get('/categorySubDelete/:categoryId',adminCategory.loggedIn, adminSubCategory.categoryDelete);81 82 /* Sub Category module end*/838485 /* userList and artist module start*/8687 app.get('/artist',adminCategory.loggedIn, adminuser.artistList);88 app.get('/listArtist', adminuser.listartist);89 app.get('/artistStatus/:categoryId/:status',adminCategory.loggedIn, adminuser.artistStatus);90 app.get('/artistview/:id',adminCategory.loggedIn, adminuser.artistview);91 app.get('/artistServicesList',adminuser.artistServicesList);9293 app.get('/customer',adminCategory.loggedIn, adminuser.userList);94 app.get('/listcutomer', adminuser.listuser);95 app.get('/customerStatus/:categoryId/:status',adminCategory.loggedIn, adminuser.userStatus);96 app.get('/customerview/:id',adminCategory.loggedIn, adminuser.customerview);9798 99 /* userList and artist end*/100101 /* profile update and change password module start*/102 103 app.post('/admin_profile_update', adminCategory.loggedIn , adminHome.admin_profile_update);104 app.post('/admin_changepassword', adminCategory.loggedIn , adminHome.admin_changepassword);105106 /* profile update and change password module start*/107108109110 /* Front module start*/111112 app.get('/frontHome',login.profileCheck, frontHome.home);113 app.get('/login', login.login);114 app.get('/businessLogin', login.businesslogin);115 app.get('/businessRegister', login.businessRegister);116 app.post('/phoneVerification', login.phoneVerification, login.sendSmsdata);117 app.get('/register', login.register);118 app.get('/userProfile',frontHome.loggedIn,login.profileCheck, frontHome.userProfile);119 app.get('/myProfile',frontHome.loggedIn,login.profileCheck,frontHome.certificateCount, frontHome.myProfile);120 app.get('/my_certificate',frontHome.loggedIn,login.profileCheck, frontHome.certificateCount, frontHome.artist_my_certificate);121 app.get('/emailCheck',login.emailCheck);122 app.get('/userLogout', frontHome.userLogout);123 app.post('/profileUpdate',frontHome.loggedIn, frontHome.userprofileUpdate);124 app.post('/certificate_upload',frontHome.certificate_upload);125 app.get('/removecertificate',frontHome.removecertificate);126 127 app.post('/socialRegister',login.socialRegister);128 app.post('/userRegister',login.UserSignup);129 app.post('/businessRegister',login.businessSignup);130 app.post('/userLogin',login.userLogin);131 app.post('/forgotPassword',login.forgotPassword,login.sendMail);132 app.get('/businessHours',frontHome.loggedIn , User.businessHours);133 app.get('/subCategoryAdd',frontHome.loggedIn,User.serviceCount,User.categorydata, User.subCategoryAdd);134 app.get('/addsubservices',frontHome.loggedIn,User.subservicesList,User.addsubservices);135 app.get('/updatesubservices',frontHome.loggedIn,User.updatesubservices);136 app.post('/update_workingTime',User.update_workingTime);137 app.post('/servicesAdd',User.serviceCount,User.AddServices);138 app.get('/registerStep3',frontHome.loggedIn, User.registerStep3);139 app.post('/certificateAdd',User.certificate_upload);140 app.post('/addBackAccount',User.addBackAccount);141 app.get('/skipstep3',frontHome.loggedIn,User.skipstep3);142143 144 app.get('/artistDashboard',frontHome.loggedIn,login.profileCheck,frontHome.artistdashboard);145 app.get('/explore',frontHome.loggedIn,login.profileCheck,explore.explore);146 app.get('/paymenthistory',frontHome.loggedIn,login.profileCheck,payment.paymenthistory);147 app.get('/bookinghistory',frontHome.loggedIn,login.profileCheck,staff.staff_List_data,staff.company_List_data,booking.bookinghistory); 148 app.post('/stripe',stripe.stripeaddAccount);149 app.get('/searchResult',booking.categoryGet,booking.searchResult);150 app.post('/search_artist',booking.search_artistdata,booking.search_artist);151 app.post('/get_sub_category',booking.get_sub_category);152 app.post('/home_search_artist',booking.home_search_artist,booking.home_search_artist_result);153 app.post('/get_sub_service',booking.get_sub_service);154 app.get('/booking_detial',frontHome.loggedInuserData,booking.locationGet,booking.userDetail,booking.Artistcategorydata,booking.booking_detial);155 app.get('/booking',frontHome.loggedInuserData,booking.loginBookingUpdate,booking.userDetail,booking.Artistcategorydata,booking.booking);156 app.get('/artistsubservices',booking.artistsubservicesList,booking.artistsubservices);157 app.get('/artistStaff',booking.artistStaff);158 app.get('/artistslot',booking.artistslot);159 app.get('/ArtistServiceDetail',booking.ArtistServiceDetail);160 app.get('/bookingServiceDetail',booking.bookingServiceDetail);161 app.post('/serviceBookingAdd',booking.serviceBookingAdd);162 app.post('/finalBooking',booking.finalBooking);163 app.post('/bookingUpdate',booking.bookingUpdate);164 app.get('/artistFreeSlot',booking.artistFreeSlot);165 app.post('/artistbookingHistory',booking.artistservicesList,booking.pendingBooking,booking.completeBooking,staff.staff_List_data,staff.company_List_data,staff.independArtistListData,booking.artistbookingHistory); 166 app.get('/artistmainsubservices',booking.Artistcategorydata,booking.artistmainsubservices);167 app.get('/bookingRemove',booking.bookingRemove);168 app.get('/bookingInfo',frontHome.loggedIn,booking.artistservicesList,booking.bookingInfoData,staff.staff_List_data,staff.independArtistListData,staff.company_List_data,booking.bookingInfo); 169 app.get('/staffManagement',frontHome.loggedIn,login.profileCheck,staff.staffManagement); 170 app.post('/staffArtistList',frontHome.loggedIn,staff.independArtistList,staff.staffArtistList); 171 app.get('/add_staff',frontHome.loggedIn,login.profileCheck,booking.userDetail,staff.artistCategoryData,staff.bussinessHoursGet,staff.staff_Info,staff.add_staff);172 app.get('/get_artistservices',staff.get_artistservices); 173 app.get('/get_artistsubservices',staff.get_artistsubservices); 174 app.post('/staffServiceAdd',staff.staffServiceAdd); 175 app.get('/ArtistStaffServiceDetail',staff.staffServiceDetail,staff.ArtistServiceDetail);176 app.get('/staffserviceList',booking.artistservicesList,staff.artistCategoryData,staff.staffServiceList);177 app.get('/removestaffservice',staff.removestaffservice);178 app.post('/staff_add',staff.staff_add);179 app.post('/staff_List',booking.artistservicesList,staff.staff_List_data,staff.company_List_data,staff.staff_List);180 app.get('/staffdetail',booking.staffdetail);181 app.post('/staffUpdate',booking.staffUpdate);182 app.post('/changstaff',staff.staff_List_data_service, staff.changstaff);183 app.get('/delete_staff',frontHome.loggedIn,staff.delete_staff);184 app.get('/profile',frontHome.certificateCount , frontHome.myProfile);185 app.get('/aboutUs',frontHome.certificateCount,frontHome.aboutUs);186 app.get('/following',frontHome.certificateCount,frontHome.following);187 app.get('/followers',frontHome.certificateCount,frontHome.followers);188 app.get('/following_list',frontHome.certificateCount,frontHome.followrsCheckData,frontHome.followingData,frontHome.following_list);189 app.get('/followers_list',frontHome.certificateCount,frontHome.followrsCheckData,frontHome.followersData,frontHome.following_list);190 app.post('/followUnfollow',frontHome.loggedIn,frontHome.followUnfollow);191 app.post('/artistFavorite',frontHome.loggedIn,frontHome.artistFavorite);192 app.post('/faveroite_list',booking.faveroite_list,booking.faveroite_list_result);193 app.get('/my_services',frontHome.certificateCount,frontService.servicesdata,frontService.serviceManagement);194195196197198/* app.post('/userLogin', passport.authenticate('local-user-login', {199 successRedirect: '/myProfile', // redirect to the secure profile section200 failureRedirect: '/login', // redirect back to the signup page if there is an error201 failureFlash: true // allow flash messages202203 }));*/204 // process the login form205 /* Front module end*/206207208 /* code start from sunil side*/209 app.post('/api/phonVerification',service.phonVerification);210 app.post('/api/artistRegistration',service.artistRegistration);211 app.post('/api/userRegistration',service.userRegistration);212 app.post('/api/forgotPassword',service.forgotPassword,service.sendMail);213 app.post('/api/userLogin',service.userLogin);214 app.get('/api/getBusinessProfile',authtokenCheck.checkaccessToken,artist.artistInfo);215 app.post('/api/addBusinessHour',authtokenCheck.checkaccessToken,artist.businessHours);216 app.post('/api/updateRange',authtokenCheck.checkaccessToken,artist.updateRange);217 app.post('/api/allService',authtokenCheck.checkaccessToken,artist.allCategory);218 app.post('/api/allCategory',authtokenCheck.checkaccessToken,appUser.allCategory);219 app.post('/api/subService',authtokenCheck.checkaccessToken,artist.subService);220 app.post('/api/addArtistService',authtokenCheck.checkaccessToken,artist.addArtistService);221 app.post('/api/addArtistCertificate',authtokenCheck.checkaccessToken,artist.addArtistCertificate);222 app.post('/api/addFeed',authtokenCheck.checkaccessToken,artist.addTag,artist.addFeed);223 app.post('/api/getAllFeeds',authtokenCheck.checkaccessToken,artist.followerFeed,artist.getAllFeeds,artist.finalFeed);224 app.post('/api/addMyStory',authtokenCheck.checkaccessToken,appUser.addMyStory);225 app.post('/api/myStory',authtokenCheck.checkaccessToken,appUser.getMyStory);226 app.post('/api/getMyStoryUser',authtokenCheck.checkaccessToken,appUser.deleteOldStory,appUser.getMyStoryUser);227 app.post('/api/test',service.test);228 app.post('/api/addFavorite',authtokenCheck.checkaccessToken,appUser.addFavorite);229 app.post('/api/artistSearch',authtokenCheck.checkaccessToken,appUser.artistSearch,appUser.finalData);230 app.post('/api/checkUser',service.checkUser);231 app.post('/api/showArtist',authtokenCheck.checkaccessToken,artist.showArtist);232 app.post('/api/getAllCertificate',authtokenCheck.checkaccessToken,artist.getAllCertificate);233 app.post('/api/deleteCertificate',authtokenCheck.checkaccessToken,artist.deleteCertificate);234 app.post('/api/addBankDetail',authtokenCheck.checkaccessToken,artist.stripeaddAccount);235 app.post('/api/updateRecord',authtokenCheck.checkaccessToken,appUser.updateRecord);236 app.post('/api/artistDetail',authtokenCheck.checkaccessToken,appUser.artistDetail,appUser.getArtistService);237 // app.post('/api/artistPost',authtokenCheck.checkaccessToken,appUser.artistPost);238 // app.post('/api/getArtistService',authtokenCheck.checkaccessToken,artist.getArtistService);239 /* app.get('/api/deleteRecord',artist.deleteRecord);*/240 // app.post('/api/artistTimeSlot',authtokenCheck.checkaccessToken,appUser.artistTimeSlot);241 app.post('/api/artistTimeSlot',authtokenCheck.checkaccessToken,appUser.getCurrentTime,appUser.bookingInfo,appUser.artistTimeSlot);242 app.post('/api/bookArtist',authtokenCheck.checkaccessToken,appUser.bookArtist);243 app.post('/api/confirmBooking',authtokenCheck.checkaccessToken,appUser.confirmBooking);244 app.post('/api/skipPage',authtokenCheck.checkaccessToken,artist.skipPage);245 app.post('/api/like',authtokenCheck.checkaccessToken,appUser.like);246 app.post('/api/commentLike',authtokenCheck.checkaccessToken,appUser.commentLike);247 app.post('/api/likeList',authtokenCheck.checkaccessToken,appUser.likeList,appUser.likeListFinal);248 app.post('/api/followFollowing',authtokenCheck.checkaccessToken,appUser.followFollowing);249 app.post('/api/followerList',authtokenCheck.checkaccessToken,appUser.followerList);250 app.post('/api/followingList',authtokenCheck.checkaccessToken,appUser.followingList);251 app.post('/api/commentList',authtokenCheck.checkaccessToken,appUser.commentList,appUser.finalCommentList);252 app.post('/api/addComment',authtokenCheck.checkaccessToken,appUser.addComment);253 app.post('/api/deleteBookService',authtokenCheck.checkaccessToken,appUser.deleteBookService);254 app.post('/api/deleteAllBookService',authtokenCheck.checkaccessToken,appUser.deleteAllBookService);255 app.post('/api/deleteUserBookService',authtokenCheck.checkaccessToken,appUser.deleteUserBookService);256 app.post('/api/addTag',authtokenCheck.checkaccessToken,appUser.addTag);257 app.post('/api/tagSearch',authtokenCheck.checkaccessToken,appUser.tagSearch);258 app.post('/api/artistFreeSlot',authtokenCheck.checkaccessToken,artist.artistBookingInfo,artist.getCurrentTime,artist.artistFreeSlot);259 app.post('/api/bookingAction',authtokenCheck.checkaccessToken,artist.bookingAction);260 app.post('/api/bookingDetails',authtokenCheck.checkaccessToken,artist.bookingDetails);261 app.post('/api/exploreSearch',authtokenCheck.checkaccessToken,appUser.exploreSearch,appUser.exploreSearchFinal);262 app.post('/api/userFeed',authtokenCheck.checkaccessToken,appUser.userFeedByTag,appUser.userFeed,appUser.finalUserFeed);263 app.post('/api/allArtist',authtokenCheck.checkaccessToken,artist.allArtist,artist.finalAllArtist);264 app.post('/api/addStaff',authtokenCheck.checkaccessToken,artist.addStaff);265 app.post('/api/addStaffService',authtokenCheck.checkaccessToken,artist.addStaffService);266 app.post('/api/artistStaff',authtokenCheck.checkaccessToken,artist.artistStaff);267 app.post('/api/feedDetails',authtokenCheck.checkaccessToken,appUser.feedDetails);268 app.post('/api/artistService',authtokenCheck.checkaccessToken,artist.artistService);269 app.post('/api/staffInformation',authtokenCheck.checkaccessToken,artist.staffInformation);270 app.post('/api/deleteStaffService',authtokenCheck.checkaccessToken,artist.deleteStaffService);271 /*code end form sunil side */272273274 /* Service module start*/275276/* app.post('/api/phoneVerification', service.verification, service.sendSms);277 app.post('/api/userRegister', service.register);278 app.post('/api/userLogin', service.userLogin);279 app.get('/api/userInfo',authtokenCheck.checkaccessToken,user.userInfo);280 app.get('/api/sendSms',service.sendSms);281 app.get('/api/categorydata',authtokenCheck.checkaccessToken,user.categoryList);*/282283284 /* Service module end*/285 ...

Full Screen

Full Screen

router.js

Source:router.js Github

copy

Full Screen

1var fs = require('fs-extra');2var postRequestsHandlers=require('./postrequests.js');3var getRequestsHandlers=require('./getrequests.js');4var deleteRequestsHandlers=require('./deleterequests.js');5var checkAccess = require('./middlewarefunctions.js').checkAccess;6var noMiddleware = require('./middlewarefunctions.js').noMiddleware;7var getRequests = [8 {9 url: '/',10 middleware: noMiddleware,11 callback: getRequestsHandlers.getFacePage12 },13 {14 url: '/new-products',15 middleware: noMiddleware,16 callback: getRequestsHandlers.getNewProductPage17 },18 {19 url: '/catalog/:id', //route of old site20 middleware: noMiddleware,21 callback: getRequestsHandlers.redirectToFace22 },23 {24 url: '/products', //route of old site25 middleware: noMiddleware,26 callback: getRequestsHandlers.redirectToFace27 },28 {29 url: '/static/:id',30 middleware: noMiddleware,31 callback: getRequestsHandlers.getStaticPage32 },33 {34 url: '/cart',35 middleware: noMiddleware,36 callback: getRequestsHandlers.getCartPage37 },38 {39 url: '/products/:id',40 middleware: noMiddleware,41 callback: getRequestsHandlers.getProductPage42 },43 {44 url: '/category/:id',45 middleware: noMiddleware,46 callback: getRequestsHandlers.getCategoryPage47 },48 {49 url: '/subcategory/:id/:subid',50 middleware: noMiddleware,51 callback: getRequestsHandlers.getSubcategoryPage52 },53 {54 url: '/pay/order/:num',55 middleware: noMiddleware,56 callback: getRequestsHandlers.getPayPage57 },58 {59 url: '/payment/success',60 middleware: noMiddleware,61 callback: getRequestsHandlers.getSuccessPage62 },63 {64 url: '/payment/fail',65 middleware: noMiddleware,66 callback: getRequestsHandlers.getFailPage67 },68 /*components routes*/69 {70 url: '/searchproduct',71 middleware: noMiddleware,72 callback: getRequestsHandlers.searchProduct73 },74 {75 url: '/getcallbackform',76 middleware: noMiddleware,77 callback: getRequestsHandlers.getCallbackForm78 },79 {80 url: '/getproductreview',81 middleware: noMiddleware,82 callback: getRequestsHandlers.getProductReview83 },84 /*admin routes*/85 {86 url: '/login',87 middleware: noMiddleware,88 callback: function(req, res) {89 res.sendFile(__dirname + '/html/login.html');90 }91 },92 {93 url: '/admin',94 middleware: checkAccess,95 callback: function(req, res) {96 res.sendFile(__dirname + '/html/admin.html');97 }98 },99 {100 url: '/admin/logout',101 middleware: checkAccess,102 callback: getRequestsHandlers.logOut103 },104 {105 url: '/admin/getnewordersquantity',106 middleware: checkAccess,107 callback: getRequestsHandlers.getNewOrdersQuantity108 },109 {110 url: '/admin/getorders',111 middleware: checkAccess,112 callback: getRequestsHandlers.getOrders113 },114 {115 url: '/admin/getorderarchive',116 middleware: checkAccess,117 callback: getRequestsHandlers.getOrderArchive118 },119 {120 url: '/admin/getmoreorderarchive',121 middleware: checkAccess,122 callback: getRequestsHandlers.getMoreOrderArchive123 },124 {125 url: '/admin/getorderdeleted',126 middleware: checkAccess,127 callback: getRequestsHandlers.getOrderDeleted128 },129 {130 url: '/admin/searchclient',131 middleware: checkAccess,132 callback: getRequestsHandlers.searchClient133 },134 {135 url: '/admin/getcategories',136 middleware: checkAccess,137 callback: getRequestsHandlers.getCategories138 },139 {140 url: '/admin/getproductaddform',141 middleware: checkAccess,142 callback: getRequestsHandlers.getProductAddForm143 },144 {145 url: '/admin/getsubcategories',146 middleware: checkAccess,147 callback: getRequestsHandlers.getSubcategories148 },149 {150 url: '/admin/getcategoryfilter',151 middleware: checkAccess,152 callback: getRequestsHandlers.getCategoryFilter153 },154 {155 url: '/admin/getproductslist',156 middleware: checkAccess,157 callback: getRequestsHandlers.getProductsList158 },159 {160 url: '/admin/getmovetocategoryform',161 middleware: checkAccess,162 callback: getRequestsHandlers.getMoveToCategoryForm163 },164 {165 url: '/admin/getchangeproductform',166 middleware: checkAccess,167 callback: getRequestsHandlers.getChangeProductForm168 },169 {170 url: '/admin/getspecialpropformforproduct',171 middleware: checkAccess,172 callback: getRequestsHandlers.getSpecialPropFormForProduct173 },174 {175 url: '/admin/getspecialpropformforcategory',176 middleware: checkAccess,177 callback: getRequestsHandlers.getSpecialPropFormForCategory178 },179 {180 url: '/admin/getspecialpropslist',181 middleware: checkAccess,182 callback: getRequestsHandlers.getSpecialPropsList183 },184 {185 url: '/admin/getcallbacklist',186 middleware: checkAccess,187 callback: getRequestsHandlers.getCallbackList188 },189 {190 url: '/admin/getfeedback',191 middleware: checkAccess,192 callback: getRequestsHandlers.getFeedback193 },194 {195 url: '/admin/getallreviews',196 middleware: checkAccess,197 callback: getRequestsHandlers.getAllReviews198 }199];200var postRequests = [201 {202 url: '/ordercallback',203 middleware: noMiddleware,204 callback: postRequestsHandlers.orderCallback205 },206 {207 url: '/makeorder',208 middleware: noMiddleware,209 callback: postRequestsHandlers.makeOrder210 },211 {212 url: '/feedback',213 middleware: noMiddleware,214 callback: postRequestsHandlers.feedback215 },216 {217 url: '/postreview',218 middleware: noMiddleware,219 callback: postRequestsHandlers.postReview220 },221 /*admin routes*/222 {223 url: '/admin',224 middleware: checkAccess,225 callback: function(req, res) {226 res.sendFile(__dirname + '/html/admin.html');227 }228 },229 {230 url: '/login',231 middleware: noMiddleware,232 callback: postRequestsHandlers.loginHandler233 },234 {235 url: '/admin/changepassword',236 middleware: checkAccess,237 callback: postRequestsHandlers.changePassword238 },239 {240 url: '/admin/changeemail',241 middleware: checkAccess,242 callback: postRequestsHandlers.changeEmail243 },244 {245 url: '/admin/addmanagercomment',246 middleware: checkAccess,247 callback: postRequestsHandlers.addManagerComment248 },249 {250 url: '/admin/setfedexprice',251 middleware: checkAccess,252 callback: postRequestsHandlers.setFedexPrice253 },254 {255 url: '/admin/ordertowork',256 middleware: checkAccess,257 callback: postRequestsHandlers.orderToWork258 },259 {260 url: '/admin/markdoneorder',261 middleware: checkAccess,262 callback: postRequestsHandlers.markDoneOrder263 },264 {265 url: '/admin/searchorderbydate',266 middleware: checkAccess,267 callback: postRequestsHandlers.searchOrderByDate268 },269 {270 url: '/admin/addcategory',271 middleware: checkAccess,272 callback: postRequestsHandlers.addCategory273 },274 {275 url: '/admin/addsubcategory',276 middleware: checkAccess,277 callback: postRequestsHandlers.addSubCategory278 },279 {280 url: '/admin/changecategory',281 middleware: checkAccess,282 callback: postRequestsHandlers.changeCategory283 },284 {285 url: '/admin/changesubcategory',286 middleware: checkAccess,287 callback: postRequestsHandlers.changeSubCategory288 },289 {290 url: '/admin/addproduct',291 middleware: checkAccess,292 callback: postRequestsHandlers.addProduct293 },294 {295 url: '/admin/changeproduct',296 middleware: checkAccess,297 callback: postRequestsHandlers.changeProduct298 },299 {300 url: '/admin/moveproduct',301 middleware: checkAccess,302 callback: postRequestsHandlers.moveProduct303 },304 {305 url: '/admin/replenishproduct',306 middleware: checkAccess,307 callback: postRequestsHandlers.replenishProduct308 },309 {310 url: '/admin/addimagetogallery',311 middleware: checkAccess,312 callback: postRequestsHandlers.addImageToGallery313 },314 {315 url: '/admin/makehit',316 middleware: checkAccess,317 callback: postRequestsHandlers.makeHit318 },319 {320 url: '/admin/makenew',321 middleware: checkAccess,322 callback: postRequestsHandlers.makeNew323 },324 {325 url: '/admin/addspecialpropforproduct',326 middleware: checkAccess,327 callback: postRequestsHandlers.addSpecialPropForProduct328 },329 {330 url: '/admin/addspecialpropforcategory',331 middleware: checkAccess,332 callback: postRequestsHandlers.addSpecialPropForCategory333 },334 {335 url: '/admin/markseencallback',336 middleware: checkAccess,337 callback: postRequestsHandlers.markSeenCallback338 },339 {340 url: '/admin/choosepage',341 middleware: checkAccess,342 callback: postRequestsHandlers.choosePage 343 },344 {345 url: '/admin/changepage',346 middleware: checkAccess,347 callback: postRequestsHandlers.changePage348 }349];350var deleteRequests = [351 {352 url: '/admin/deletecategory',353 middleware: checkAccess,354 callback: deleteRequestsHandlers.deleteCategory355 },356 {357 url: '/admin/deletesubcategory',358 middleware: checkAccess,359 callback: deleteRequestsHandlers.deleteSubCategory360 },361 {362 url: '/admin/deleteproduct',363 middleware: checkAccess,364 callback: deleteRequestsHandlers.deleteProduct365 },366 {367 url: '/admin/deleteimage',368 middleware: checkAccess,369 callback: deleteRequestsHandlers.deleteImage370 },371 {372 url: '/admin/deletespecialprop',373 middleware: checkAccess,374 callback: deleteRequestsHandlers.deleteSpecialProp375 },376 {377 url: '/admin/deletecallback',378 middleware: checkAccess,379 callback: deleteRequestsHandlers.deleteCallback380 },381 {382 url: '/admin/deleteorder',383 middleware: checkAccess,384 callback: deleteRequestsHandlers.deleteOrder385 },386 {387 url: '/admin/deleteorderpermanently',388 middleware: checkAccess,389 callback: deleteRequestsHandlers.deleteOrderPermanently390 },391 {392 url: '/admin/deletefeedback',393 middleware: checkAccess,394 callback: deleteRequestsHandlers.deleteFeedback395 },396 {397 url: '/admin/deletereview',398 middleware: checkAccess,399 callback: deleteRequestsHandlers.deleteReview400 }401];402var router = function (app) {403 getRequests.forEach(function(request){404 app.get(request.url, request.middleware, request.callback);405 });406 postRequests.forEach(function(request){407 app.post(request.url, request.middleware, request.callback)408 });409 deleteRequests.forEach(function(request){410 app.delete(request.url, request.middleware, request.callback)411 });412};...

Full Screen

Full Screen

server.js

Source:server.js Github

copy

Full Screen

1// vile/server.js2var _ = require('lodash');3var colors = require('colors');4var express = require('express');5var bodyParser = require('body-parser')6var cors = require('cors')7var fs = require('fs');8var path = require('path');9var compression = require('compression')10var http = require('http');11var request = require('request');12var winston = require('winston');13// #########################################14// ### Server, routes ### // runs on 1 cpu15// #########################################16module.exports = function (mile) {17 // configure server18 var app = express();19 app.use(compression()); // enable compression20 app.use(bodyParser.json({ limit: '1000mb'}));21 app.use(express.static(path.join(__dirname, 'public'))); // not secured22 // create layer23 app.post('/v2/tiles/create', mile.checkAccess, function (req, res) {24 mile.createLayer(req, res);25 });26 // pre-render layer27 app.post('/v2/tiles/render', mile.checkAccess, function (req, res) {28 mile.preRender(req,res);29 });30 31 // pre-render layer32 app.post('/v2/cubes/render/start', mile.checkAccess, function (req, res) {33 mile.cubes.render.start(req,res);34 });35 // pre-render layer36 app.post('/v2/cubes/render/status', mile.checkAccess, function (req, res) {37 mile.cubes.render.status(req,res);38 });39 // pre-render layer40 app.post('/v2/cubes/render/estimate', mile.checkAccess, function (req, res) {41 mile.cubes.render.estimate(req,res);42 });43 // create cube layer44 app.post('/v2/cubes/create', mile.checkAccess, function (req, res) {45 mile.cubes.create(req, res);46 });47 // remove cube layer48 app.post('/v2/cubes/deleteCube', mile.checkAccess, function (req, res) {49 mile.cubes.deleteCube(req, res);50 });51 // add dataset to cube52 app.post('/v2/cubes/add', mile.checkAccess, function (req, res) {53 mile.cubes.add(req, res);54 });55 // remove dataset from cube56 app.post('/v2/cubes/remove', mile.checkAccess, function (req, res) {57 mile.cubes.remove(req, res);58 });59 // replace dataset60 app.post('/v2/cubes/replace', mile.checkAccess, function (req, res) {61 mile.cubes.replace(req, res);62 });63 // update dataset64 app.post('/v2/cubes/update', mile.checkAccess, function (req, res) {65 mile.cubes.update(req, res);66 });67 // add mask68 app.post('/v2/cubes/mask', mile.checkAccess, function (req, res) {69 mile.cubes.mask(req, res);70 });71 // remove mask72 app.post('/v2/cubes/unmask', mile.checkAccess, function (req, res) {73 mile.cubes.unmask(req, res);74 });75 // get mask76 app.post('/v2/cubes/getMask', mile.checkAccess, function (req, res) {77 mile.cubes.getMask(req, res);78 });79 // update mask80 app.post('/v2/cubes/updateMask', mile.checkAccess, function (req, res) {81 mile.cubes.updateMask(req, res);82 });83 // update mask84 app.post('/v2/cubes/updateDatasetMask', mile.checkAccess, function (req, res) {85 mile.cubes.updateMask(req, res);86 });87 // request cube tiles88 app.get('/v2/cubes/get', mile.checkAccess, function (req, res) {89 mile.cubes.get(req, res);90 });91 // create cube layer92 app.get('/v2/cubes/*', mile.checkAccess, function (req, res) {93 mile.cubes.tile(req, res);94 });95 // vectorize layer96 app.post('/v2/tiles/vectorize', mile.checkAccess, function (req, res) {97 mile.vectorizeDataset(req, res);98 });99 // get layer100 app.get('/v2/tiles/layer', mile.checkAccess, function (req, res) {101 mile.getLayer(req, res);102 });103 // get tiles104 app.get('/v2/tiles/*', mile.checkAccess, function (req, res) {105 mile.getTileEntryPoint(req, res);106 });107 // get data from point108 app.post('/v2/query/point', mile.checkAccess, function (req, res) {109 mile.fetchData(req, res);110 });111 // get data from area112 app.post('/v2/query/polygon', mile.checkAccess, function (req, res) {113 mile.fetchDataArea(req, res);114 });115 // get data from area116 app.post('/v2/query/defo', mile.checkAccess, function (req, res) {117 mile.fetchRasterDeformation(req, res);118 });119 // get data from area120 app.post('/v2/query/raster/point', mile.checkAccess, function (req, res) {121 mile.queryRasterPoint(req, res);122 });123 // get data from area for cube124 app.post('/v2/cubes/query', mile.checkAccess, function (req, res) {125 mile.cubes.query(req, res);126 });127 // get histogram from column128 app.post('/v2/query/histogram', mile.checkAccess, function (req, res) {129 mile.fetchHistogram(req, res);130 });131 // get histogram from column132 app.post('/v2/query/getVectorPoints', mile.checkAccess, function (req, res) {133 mile.getVectorPoints(req, res);134 });135 // start server136 app.listen(3003);137 // debug138 console.log('\n\nMile is up @ ' + 3003);139}140// tile render logging141console.tile = function (tile) {142 // if (tile.render_time) console.info('rendered tile in ', tile.render_time, 'ms');...

Full Screen

Full Screen

access.spec.js

Source:access.spec.js Github

copy

Full Screen

...8 * @param auth {object} disable auth9 * @param pkg {string} package name10 * @param ok {boolean}11 */12 function checkAccess(auth, pkg, ok) {13 test(14 (ok ? 'allows' : 'forbids') +' access ' + auth + ' to ' + pkg,15 () => {16 server.authstr = auth ? buildToken(auth) : undefined;17 let req = server.getPackage(pkg);18 if (ok) {19 return req.status(404).body_error(/no such package available/);20 } else {21 return req.status(403).body_error(/not allowed to access package/);22 }23 }24 );25 }26 /**27 * Check whether the user is allowed to publish packages28 * @param auth {object} disable auth29 * @param pkg {string} package name30 * @param ok {boolean}31 */32 function checkPublish(auth, pkg, ok) {33 test(`${(ok ? 'allows' : 'forbids')} publish ${auth} to ${pkg}`, () => {34 server.authstr = auth ? buildToken(auth) : undefined;35 const req = server.putPackage(pkg, require('../fixtures/package')(pkg));36 if (ok) {37 return req.status(404).body_error(/this package cannot be added/);38 } else {39 return req.status(403).body_error(/not allowed to publish package/);40 }41 });42 }43 // credentials44 const badCredentials = 'test:badpass';45 // test user is logged by default46 const validCredentials = 'test:test';47 // defined on server1 configuration48 const testAccessOnly = 'test-access-only';49 const testPublishOnly = 'test-publish-only';50 const testOnlyTest = 'test-only-test';51 const testOnlyAuth = 'test-only-auth';52 // all are allowed to access53 checkAccess(validCredentials, testAccessOnly, true);54 checkAccess(undefined, testAccessOnly, true);55 checkAccess(badCredentials, testAccessOnly, true);56 checkPublish(validCredentials, testAccessOnly, false);57 checkPublish(undefined, testAccessOnly, false);58 checkPublish(badCredentials, testAccessOnly, false);59 // all are allowed to publish60 checkAccess(validCredentials, testPublishOnly, false);61 checkAccess(undefined, testPublishOnly, false);62 checkAccess(badCredentials, testPublishOnly, false);63 checkPublish(validCredentials, testPublishOnly, true);64 checkPublish(undefined, testPublishOnly, true);65 checkPublish(badCredentials, testPublishOnly, true);66 // only user "test" is allowed to publish and access67 checkAccess(validCredentials, testOnlyTest, true);68 checkAccess(undefined, testOnlyTest, false);69 checkAccess(badCredentials, testOnlyTest, false);70 checkPublish(validCredentials, testOnlyTest, true);71 checkPublish(undefined, testOnlyTest, false);72 checkPublish(badCredentials, testOnlyTest, false);73 // only authenticated users are allowed74 checkAccess(validCredentials, testOnlyAuth, true);75 checkAccess(undefined, testOnlyAuth, false);76 checkAccess(badCredentials, testOnlyAuth, false);77 checkPublish(validCredentials, testOnlyAuth, true);78 checkPublish(undefined, testOnlyAuth, false);79 checkPublish(badCredentials, testOnlyAuth, false);80 });...

Full Screen

Full Screen

todolists.js

Source:todolists.js Github

copy

Full Screen

1const { TodoLists } = require('../models')2const checkListExistAndAccess = require('./utils')3module.exports = (pool) => {4 const db = {}5 db.addList = async (list) => {6 const res = await pool.query(7 'INSERT INTO TodoLists (name) VALUES ($1) RETURNING *',8 [list.name]9 ) 10 return new TodoLists(res.rows[0])11 }12 db.removeList = async (id, uid) => {13 const checkAccess = await checkListExistAndAccess(pool, id, uid)14 if (checkAccess !== 200) {15 return checkAccess16 }17 const res = await pool.query(18 `DELETE From UserAccess 19 WHERE listid = $1`,20 [id]21 )22 return res.rowCount23 }24 db.updateList = async (id, uid, list) => {25 const checkAccess = await checkListExistAndAccess(pool, id, uid)26 if (checkAccess !== 200) {27 return checkAccess28 }29 const res = await pool.query(30 'UPDATE TodoLists SET name=$2 WHERE id=$1 RETURNING *',31 [id, list.name]32 )33 return new TodoLists({...res.rows[0]})34 }35 db.getAllLists = async (uid) => {36 const res = await pool.query(37 `SELECT id, name FROM TodoLists 38 WHERE id IN (39 SELECT listid FROM UserAccess 40 WHERE uid = $141 )`42 ,[uid]43 )44 if (res.rows.length > 0){45 const toReturn = res.rows.map(row => {46 return new TodoLists({id:row.id, name:row.name})47 })48 return toReturn;49 } else return {}50 }51 db.getListById = async (listid, uid) => {52 const checkAccess = await checkListExistAndAccess(pool, listid, uid)53 if (checkAccess !== 200) {54 return checkAccess55 }56 const res = await pool.query(57 `SELECT id,name FROM TodoItems58 WHERE todolistid IN (59 SELECT listid FROM UserAccess 60 WHERE uid = $1 AND61 listid = $262 ) AND63 enable = $3`,[uid, listid, true]64 )65 return res.rows;66 }67 68 return db;...

Full Screen

Full Screen

todoitems.js

Source:todoitems.js Github

copy

Full Screen

1const { TodoItems } = require('../models')2const checkListExistAndAccess = require('./utils')3module.exports = (pool) => {4 const db = {}5 db.addItem = async (item, uid) => {6 const listId = item.todoListId7 const checkAccess = await checkListExistAndAccess(pool, listId, uid)8 if (checkAccess !== 200) {9 return checkAccess10 }11 const res = await pool.query(12 'INSERT INTO TodoItems (name, enable, todolistid) VALUES ($1,$2,$3) RETURNING *',13 [item.name, true, listId]14 )15 return new TodoItems(res.rows[0])16 }17 db.removeItem = async (id, uid) => {18 const listId = await pool.query(19 `SELECT todolistid FROM todoitems20 WHERE id=$1 AND enable=$2`,21 [id, true]22 )23 if (listId.rows.length == 0){24 return 40425 }26 const checkAccess = await checkListExistAndAccess(pool, listId.rows[0].todolistid, uid)27 if (checkAccess !== 200) {28 return checkAccess29 }30 const res = await pool.query(31 'UPDATE TodoItems SET enable=$2 WHERE id=$1 RETURNING name',32 [id, false]33 )34 return new TodoItems(res.rows[0])35 }36 db.updateItem = async (id, uid, item) => {37 const listId = await pool.query(38 `SELECT todolistid FROM todoitems39 WHERE id=$1 AND enable=$2`,40 [id, true]41 )42 if (listId.rows.length == 0){43 return 40444 }45 const checkAccess = await checkListExistAndAccess(pool, listId.rows[0].todolistid, uid)46 if (checkAccess !== 200) {47 return checkAccess48 }49 const res = await pool.query(50 'UPDATE TodoItems SET name=$2 WHERE id=$1 RETURNING *',51 [id, item.name]52 )53 return new TodoItems(res.rows[0])54 }55 return db;...

Full Screen

Full Screen

arrays.js

Source:arrays.js Github

copy

Full Screen

2var string1 = 'r_liteprofile r_emailaddress w_member_social',3 string2 = 'r_liteprofile r_emailaddress',4 string3 = 'r_liteprofile';5// let checkAccess = (cookieArray, linkedinArray) => linkedinArray.every(arrayValue => cookieArray.indexOf(arrayValue) >= 0);6var checkAccess = function checkAccess(cookieString, permissionsString) {7 var cookieArray = cookieString.split(" ");8 var permissionsArray = permissionsString.split(" ");9 return permissionsArray.every(function (arrayValue) {10 return cookieArray.indexOf(arrayValue) >= 0;11 });12};13// eslint-disable-next-line no-console14console.log(checkAccess(string2, string1));15// eslint-disable-next-line no-console16console.log(checkAccess(string3, string1));17// eslint-disable-next-line no-console18console.log(checkAccess(string1, string2));19// eslint-disable-next-line no-console20console.log(checkAccess(string2, string3));21var cookieString = "";22// eslint-disable-next-line no-console23console.log(cookieString.split(" "));24function hasAccess(permissionsString) {25 var cookieString = cookieManager.get(LI_ACC_SCOPES) || "";26 var cookieArray = cookieString.split(" ");27 var permissionsArray = permissionsString.split(" ");28 return permissionsArray.every(function (arrayValue) {29 return cookieArray.indexOf(arrayValue) >= 0;30 });...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('My First Test', () => {2 it('Does not do much!', () => {3 cy.contains('type').click()4 cy.url().should('include', '/commands/actions')5 cy.get('.action-email')6 .type('

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('My First Test', function() {2 it('Does not do much!', function() {3 cy.contains('type').click()4 cy.url().should('include', '/commands/actions')5 cy.get('.action-email')6 .type('

Full Screen

Using AI Code Generation

copy

Full Screen

1Cypress.Commands.add('checkAccess', (path, status) => {2 cy.request({3 }).then((response) => {4 expect(response.status).to.eq(status)5 })6})7describe('My First Test', () => {8 it('Does not do much!', () => {9 cy.checkAccess('/commands/actions', 200)10 })11})12Cypress.Commands.add('checkAccess', (path, status) => {13 cy.request({14 }).then((response) => {15 expect(response.status).to.eq(status)16 })17})18describe('My First Test', () => {19 it('Does not do much!', () => {20 cy.checkAccess('/commands/actions', 200)21 })22})23describe('My First Test', () => {24 it('Does not do much!', () => {25 cy.checkAccess('/commands/actions', 200)26 })27})28describe('My First Test', () => {29 it('Does not do much!', () => {30 cy.checkAccess('/commands/actions', 200)31 })32})33describe('My First Test', () => {34 it('Does not do much!', () => {35 cy.checkAccess('/commands/actions', 200)36 })37})38describe('My First Test', () => {39 it('Does not do much!', () => {40 cy.checkAccess('/commands/actions', 200)41 })42})43describe('My First Test', () => {44 it('Does not do much!', () => {

Full Screen

Using AI Code Generation

copy

Full Screen

1cy.checkAccess('admin', 'admin');2cy.checkAccess('admin1', 'admin1');3cy.checkAccess('admin2', 'admin2');4cy.checkAccess('admin3', 'admin3');5cy.checkAccess('admin4', 'admin4');6cy.checkAccess('admin5', 'admin5');7cy.checkAccess('admin6', 'admin6');8cy.checkAccess('admin7', 'admin7');9cy.checkAccess('admin8', 'admin8');10cy.checkAccess('admin9', 'admin9');11cy.checkAccess('admin10', 'admin10');12cy.checkAccess('admin11', 'admin11');13cy.checkAccess('admin12', 'admin12');14cy.checkAccess('admin13', 'admin13');15cy.checkAccess('admin14', 'admin14');16cy.checkAccess('admin15', 'admin15');17cy.checkAccess('admin16', 'admin16');18cy.checkAccess('admin17', 'admin17');19cy.checkAccess('admin18', 'admin18');20cy.checkAccess('admin19', 'admin19');21cy.checkAccess('admin20', 'admin20');22cy.checkAccess('admin21', 'admin21');23cy.checkAccess('admin22', 'admin22');24cy.checkAccess('admin23', 'admin23');

Full Screen

Using AI Code Generation

copy

Full Screen

1var cypress = require('cypress');2 if (err) {3 console.log(err);4 }5 else {6 console.log(res);7 }8});9var cypress = require('cypress');10 if (err) {11 console.log(err);12 }13 else {14 console.log(res);15 }16});17var cypress = require('cypress');18 if (err) {19 console.log(err);20 }21 else {22 console.log(res);23 }24});25var cypress = require('cypress');26 if (err) {27 console.log(err);28 }29 else {30 console.log(res);31 }32});33var cypress = require('cypress');34 if (err) {35 console.log(err);36 }37 else {38 console.log(res);39 }40});41var cypress = require('cypress');42 if (err) {43 console.log(err);44 }45 else {46 console.log(res);47 }48});49var cypress = require('cypress');50 if (err) {51 console.log(err);52 }53 else {54 console.log(res);55 }56});57var cypress = require('cypress');58 if (err) {59 console.log(err);60 }61 else {

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('My First Test', function() {2 it('Does not do much!', function() {3 })4})5Cypress.Commands.add('checkAccess', (url) => {6 cy.request({7 }).its('status').should('be.oneOf', [200, 401])8})9import './commands'

Full Screen

Using AI Code Generation

copy

Full Screen

1cy.checkAccess('test.js', 'rwx', 'u')2cy.checkAccess('test.js', 'rwx', 'g')3cy.checkAccess('test.js', 'rwx', 'o')4cy.checkAccess('test.js', 'rwx', 'u')5cy.checkAccess('test.js', 'rwx', 'g')6cy.checkAccess('test.js', 'rwx', 'o')7cy.checkAccess('test.js', 'rwx', 'u')8cy.checkAccess('test.js', 'rwx', 'g')9cy.checkAccess('test.js', 'rwx', 'o')10cy.checkAccess('test.js', 'rwx', 'u')11cy.checkAccess('test.js', 'rwx', 'g')12cy.checkAccess('test.js', 'rwx', 'o')13cy.checkAccess('test.js', 'rwx', 'u')14cy.checkAccess('test.js', 'rwx', 'g')15cy.checkAccess('test.js', 'rwx', 'o')16cy.checkAccess('test.js', 'rwx', 'u')17cy.checkAccess('test.js', 'rwx', 'g')18cy.checkAccess('test.js', 'rwx', 'o')19cy.checkAccess('test.js', 'rwx', '

Full Screen

Using AI Code Generation

copy

Full Screen

1cy.checkAccess('admin');2cy.checkAccess('admin', 'user');3cy.checkAccess('admin', 'user', 'manager');4cy.checkAccess('admin', 'user', 'manager', 'superAdmin');5cy.checkAccess('admin', 'user', 'manager', 'superAdmin', 'student');6cy.checkAccess('admin', 'user', 'manager', 'superAdmin', 'student', 'teacher');7cy.checkAccess('admin', 'user', 'manager', 'superAdmin', 'student', 'teacher', 'parent');8cy.checkAccess('admin', 'user', 'manager', 'superAdmin', 'student', 'teacher', 'parent', 'guest');

Full Screen

Cypress Tutorial

Cypress is a renowned Javascript-based open-source, easy-to-use end-to-end testing framework primarily used for testing web applications. Cypress is a relatively new player in the automation testing space and has been gaining much traction lately, as evidenced by the number of Forks (2.7K) and Stars (42.1K) for the project. LambdaTest’s Cypress Tutorial covers step-by-step guides that will help you learn from the basics till you run automation tests on LambdaTest.

Chapters:

  1. What is Cypress? -
  2. Why Cypress? - Learn why Cypress might be a good choice for testing your web applications.
  3. Features of Cypress Testing - Learn about features that make Cypress a powerful and flexible tool for testing web applications.
  4. Cypress Drawbacks - Although Cypress has many strengths, it has a few limitations that you should be aware of.
  5. Cypress Architecture - Learn more about Cypress architecture and how it is designed to be run directly in the browser, i.e., it does not have any additional servers.
  6. Browsers Supported by Cypress - Cypress is built on top of the Electron browser, supporting all modern web browsers. Learn browsers that support Cypress.
  7. Selenium vs Cypress: A Detailed Comparison - Compare and explore some key differences in terms of their design and features.
  8. Cypress Learning: Best Practices - Take a deep dive into some of the best practices you should use to avoid anti-patterns in your automation tests.
  9. How To Run Cypress Tests on LambdaTest? - Set up a LambdaTest account, and now you are all set to learn how to run Cypress tests.

Certification

You can elevate your expertise with end-to-end testing using the Cypress automation framework and stay one step ahead in your career by earning a Cypress certification. Check out our Cypress 101 Certification.

YouTube

Watch this 3 hours of complete tutorial to learn the basics of Cypress and various Cypress commands with the Cypress testing at LambdaTest.

Run Cypress automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful