当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Application.post方法代码示例

本文整理汇总了TypeScript中express.Application.post方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Application.post方法的具体用法?TypeScript Application.post怎么用?TypeScript Application.post使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在express.Application的用法示例。


在下文中一共展示了Application.post方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: function

export var setupVerbRoutes = function (baseUrl: string, expressApp: Application) {
  var verbHandler: VerbHandler = new VerbHandler();

  var verbController: VerbController = new VerbController(verbHandler);

  expressApp.get(baseUrl + "verb/get", async (req, res) => {
    verbController.getAll(req, res);
  });

  expressApp.get(baseUrl + "verb/get/:id", async (req, res) => {
    verbController.getOne(req, res);
  });

  expressApp.post(baseUrl + "verb/create", isAuthenticatedApiMiddleware, async (req, res) => {
    verbController.create(req, res);
  });

  expressApp.post(baseUrl + "verb/update", isAuthenticatedApiMiddleware, async (req, res) => {
    verbController.update(req, res);
  });

  expressApp.post(baseUrl + "verb/remove", isAuthenticatedApiMiddleware, async (req, res) => {
    verbController.remove(req, res);
  });
}
开发者ID:haestflod,项目名称:glossarytraining,代码行数:25,代码来源:VerbController.ts

示例2: function

export var setupCategoryRoutes = function (baseUrl: string, expressApp: Application) {
  const categoryHandler = new CategoryHandler();

  const categoryController = new CategoryController(categoryHandler);

  expressApp.get(baseUrl + "category/get", async (req, res) => {
    categoryController.getAll(req, res);
  });

  expressApp.get(baseUrl + "category/get/:id", async (req, res) => {
    categoryController.getOne(req, res);
  });

  expressApp.post(baseUrl + "category/create", isAuthenticatedApiMiddleware, async (req, res) => {
    categoryController.create(req, res);
  });

  expressApp.post(baseUrl + "category/update", isAuthenticatedApiMiddleware, async (req, res) => {
    categoryController.update(req, res);
  });

  expressApp.post(baseUrl + "category/remove", isAuthenticatedApiMiddleware, async (req, res) => {
    categoryController.remove(req, res);
  });

  expressApp.get(baseUrl + "category/hasphrases", async (req, res) => {
    categoryController.allHasPhrases(req, res);
  });
};
开发者ID:haestflod,项目名称:glossarytraining,代码行数:29,代码来源:CategoryController.ts

示例3: function

export var setupPhraseRoutes = function (baseUrl: string, expressApp: Application) {
  const categoryHandler = new CategoryHandler();
  const phraseHandler = new PhraseHandler(categoryHandler);

  const phraseController = new PhraseController(phraseHandler);

  expressApp.get(baseUrl + "phrase/get", async (req, res) => {
    phraseController.getAll(req, res);
  });

  expressApp.get(baseUrl + "phrase/get/:id", async (req, res) => {
    phraseController.getOne(req, res);
  });

  expressApp.post(baseUrl + "phrase/create", isAuthenticatedApiMiddleware, async (req, res) => {
    phraseController.createPhrase(req, res);
  });

  expressApp.post(baseUrl + "phrase/update", isAuthenticatedApiMiddleware, async (req, res) => {
    phraseController.updatePhrase(req, res);
  });

  expressApp.post(baseUrl + "phrase/remove", isAuthenticatedApiMiddleware, async (req, res) => {
    phraseController.removePhrase(req, res);
  });

  expressApp.get(baseUrl + "phrase/category/:id", async (req, res) => {
    phraseController.getPhrasesForCategory(req, res);
  });
};
开发者ID:haestflod,项目名称:glossarytraining,代码行数:30,代码来源:PhraseController.ts

示例4: MakeRoutes

    public static MakeRoutes(express: Application): void {
        const keys = Object.keys(routes);
        Server.Log('Registering routes: ', keys);

        for (let key in keys) {
            key = keys[key];
            if (!routes.hasOwnProperty(key)) {
                continue;
            }

            let route = routes[key];
            let split = key.split(' ');

            if (split[0] === 'post') {
                express.post(split[1], route);
            } else {
                express.get(split.length === 1 ? split[0] : split[1], route);
            }
        }

        express.use(function(req: Request, res: Response) {
            res.status(404).render('errors/404.html', { title: '404: File Not Found' });
        });

        express.use(function(error: Error, req: Request, res: Response, next: any) {
            res.status(500).render('errors/500.html', { title: '500: Internal Server Error', error: error });
        });
    }
开发者ID:Garland220,项目名称:tabletop-audio-player,代码行数:28,代码来源:Routes.ts

示例5: model

 config.collections.forEach((schema: ISchema) => {
   const modelSchema = model(schema);
   app.get(`/${schema.name}`, async (_req: IRequest, res: Response) =>
     res.status(200).json(await modelSchema.find()),
   );
   app.get(`/${schema.name}/:id`, async (req: IRequest, res: Response) => {
     try {
       res.status(200).json(await modelSchema.findOne({_id: req.params.id}));
     } catch (err) {
       res.status(404).json({error: "Not Found"});
     }
   });
   app.post(`/${schema.name}`, async (req: IRequest, res: Response) => {
     try {
       const newModel = new modelSchema(req.body);
       await newModel.save();
       res.status(201).json(newModel);
     } catch (err) {
       res.status(400).json({error: err.message});
     }
   });
   /*
   app.put(`/${schema.name}/:id`, async (req: IRequest, res: Response) => {
     //
   });
   app.patch(`/${schema.name}/:id`, async (req: IRequest, res: Response) => {
     //
   });
   app.delete(`/${schema.name}/:id`, (req: IRequest, res: Response) => {
     //
   });
   */
 });
开发者ID:dandart,项目名称:arsebeatfish,代码行数:33,代码来源:index.ts

示例6: connectGraphql

export function connectGraphql(app: Application, schema: graphql.GraphQLSchema) {
  app.post("/graphql", (req: IGetUserAuthInfoRequest, res: Response) => {
    graphql.graphql(schema, req.body, { user: req.user })
      .then((data) => {
        res.send(JSON.stringify(data));
      });
  });
}
开发者ID:charlesponti,项目名称:cthulhu,代码行数:8,代码来源:graphql.ts

示例7: function

export default function(app: Application, apiRoot: string) {
  var id = "/:id(\\d+)";
  app.get(apiRoot, send(req => Product.findAll()));
  app.get(apiRoot + id, send(req => Product.find(+req.params.id)));
  app.post(apiRoot, send(req => {
    var data = req.body;
    delete data.id;
    return Product.create(data);
  }));
  app.put(apiRoot + id, send(req => Product.update(req.body, { where: { id: +req.params.id } }), 200));
  app.delete(apiRoot + id, send(req => Product.destroy({ where: { id: +req.params.id } }), 204));
}
开发者ID:jussik,项目名称:ssgl,代码行数:12,代码来源:product-ctrl.ts

示例8: function

export var setupQuizRoutes = function (baseUrl: string, expressApp: Application) {
  const categoryHandler = new CategoryHandler();
  const phraseHandler = new PhraseHandler(categoryHandler);
  const quizHandler = new QuizHandler(phraseHandler);
  const quizPhrasesHandler = new QuizPhrasesHandler(quizHandler, phraseHandler);

  const quizController = new QuizController(quizHandler, quizPhrasesHandler);

  expressApp.get(baseUrl + "quiz/get", async (req, res) => {
    quizController.getAll(req, res);
  });

  expressApp.get(baseUrl + "quiz/get/:id", async (req, res) => {
    quizController.getOne(req, res);
  });

  expressApp.post(baseUrl + "quiz/create", isAuthenticatedApiMiddleware, async (req, res) => {
    quizController.createQuiz(req, res);
  });

  expressApp.post(baseUrl + "quiz/update", isAuthenticatedApiMiddleware, async (req, res) => {
    quizController.updateQuiz(req, res);
  });

  expressApp.post(baseUrl + "quiz/remove", isAuthenticatedApiMiddleware, async (req, res) => {
    quizController.removeQuiz(req, res);
  });

  expressApp.get(baseUrl + "quiz/hasphrases", async (req, res) => {
    quizController.getAllHasPhrases(req, res);
  });

  expressApp.post(baseUrl + "quiz/addphrase", isAuthenticatedApiMiddleware, async (req, res) => {
    quizController.addPhraseToQuiz(req, res);
  });

  expressApp.post(baseUrl + "quiz/removephrase", isAuthenticatedApiMiddleware, async (req, res) => {
    quizController.removePhraseFromQuiz(req, res);
  });
};
开发者ID:haestflod,项目名称:glossarytraining,代码行数:40,代码来源:QuizController.ts

示例9: setupAuthRoutes

function setupAuthRoutes(app: Application, passport:Passport){

	app.get('/login', function(req, res){ res.render("login"); });    
	app.get('/signup', function(req, res){ res.render("signup"); });    
     
	app.post('/auth/signup', authFunction.localSignup);
	app.post('/auth/login', authFunction.localLogin);

	app.get('/auth/facebook', passport.authenticate('facebook', {scope: ['email']}));
	app.get('/auth/google', passport.authenticate('google', {scope: ['profile', 'email']}));

	app.get('/auth/facebook/callback', function(req:Request, res:Response, next:NextFunction) {
		 passport.authenticate('facebook', {session:false}, function(err, token:string, info) {
    		if (!token) {
      			res.json({ success: false, message: 'Facebook authentication failed.' });
    		} else {
				authSuccessRedirect(res, token);
    		}
  		})(req, res, next);
	});

	app.get('/auth/google/callback', function(req:Request, res:Response, next:NextFunction) {
		passport.authenticate('google', { session:false}, function(err, token:string, info) {
    		if (!token) {
      			res.json({ success: false, message: 'Google authentication failed.' });
    		} else {
				authSuccessRedirect(res, token);
    		}
  		})(req, res, next);
	});

	app.get('/logout', function(req, res){
		req.logout();
		res.redirect('/');
	}) ;
}
开发者ID:ychebotarev,项目名称:InColUn-v0,代码行数:36,代码来源:auth.ts

示例10: default


//.........这里部分代码省略.........
    }));

    // Marks article read, requires authentication.

    app.put('/article/:uuid/read', authed, api(async (req, tx) => {
        const uuid = req.params.uuid;
        return articleRepo.markRead(tx, uuid, true);
    }));

    // Marks article unread, requires authentication.

    app.put('/article/:uuid/unread', authed, api(async (req, tx) => {
        const uuid = req.params.uuid;
        return articleRepo.markRead(tx, uuid, false);
    }));

    // Marks all feed articles read, requires authentication.

    app.put('/feed/:uuid/read', authed, api(async (req, tx) => {
        const uuid = req.params.uuid;
        return articleRepo.markFeedRead(tx, uuid);
    }));

    // Marks all feed articles seen, requires authentication.

    app.put('/feed/:uuid/seen', authed, api(async (req, tx) => {
        const uuid = req.params.uuid;
        return articleRepo.markFeedSeen(tx, uuid);
    }));

    // Marks article important, requires authentication.

    app.put('/article/:uuid/important', authed, api(async (req, tx) => {
        const uuid = req.params.uuid;
        return articleRepo.markImportant(tx, uuid, true);
    }));

    // Marks article unimportant, requires authentication.

    app.put('/article/:uuid/unimportant', authed, api(async (req, tx) => {
        const uuid = req.params.uuid;
        return articleRepo.markImportant(tx, uuid, false);
    }));

    // Marks batch of articles seen.
    // Needs JSON array of article uuids.

    app.put('/seen', authed, bodyParser.json(), api(async (req, tx) => {
        const uuids = req.body;
        return articleRepo.markSeen(tx, uuids);
    }));

    // Deletes the given feed.
    // Requires authentication.

    app.delete('/feed/:uuid', authed, api(async (req, tx) => {
        const uuid = req.params.uuid;
        await articleRepo.removeFeed(tx, uuid);
        await feedRepo.remove(tx, uuid);
    }));

    // Marks given feed error resolved.
    // Requires authentication.

    app.put('/feed/:uuid/resolve', authed, api(async (req, tx) => {
        const uuid = req.params.uuid;
        return feedRepo.resolve(tx, uuid);
    }));

    // Adds all given feed URLs.
    // Requires authentication.

    app.post('/urls', authed, bodyParser.json(), api(async (req, tx) => {
        const urls = req.body;
        return feedRepo.addAll(tx, urls);
    }));

    // Authenticates and sets cookie for identification.

    app.post('/login', bodyParser.json(), api(async (req) => {
        const user = req.body.user;
        const pass = req.body.pass;
        const users = config.auth;
        const ok = users.some((u) => {
            return u.user === user && u.pass === pass;
        });
        if (ok) {
            req.setAuthenticated(true);
            return { ok: true };
        } else {
            return { ok: false };
        }
    }));

    // Deauthenticates the user.

    app.post('/logout', api(async (req) => {
        req.setAuthenticated(false);
    }));
};
开发者ID:rla,项目名称:feeds,代码行数:101,代码来源:api.ts


注:本文中的express.Application.post方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。