本文整理匯總了TypeScript中@feathersjs/express.rest函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript rest函數的具體用法?TypeScript rest怎麽用?TypeScript rest使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了rest函數的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: before
before(() => {
const restApp = express.default(feathers())
.use(express.json())
.configure(express.rest())
.use(express.parseAuthentication('jwt'));
app = getApp(restApp as unknown as FeathersApplication) as express.Application;
app.use(express.errorHandler());
server = app.listen(9776);
});
示例2: createApp
export default async function createApp() {
log('Creating Feathers App');
await mongoose.connect(mongoUrl, { useNewUrlParser: true });
await setupSteam();
const app = express(feathers<ServerApp>());
app
.use(express.json())
.use(express.urlencoded({ extended: true }))
.use(cookie())
.hooks(hooks)
.configure(express.rest())
.configure(socketio({ path: '/ws/' }, (io) => {
io.on('connection', (socket: ServerSocket) => {
app.emit('socket-connection', socket);
});
}))
.configure(configureDebug)
.configure(services)
.configure(configureChannels);
app
.use(express.notFound({ verbose: true }))
.use(express.errorHandler({
html(error, _, res) {
res.send(render(error));
},
logger: false,
}));
log('Created Feathers App');
return app;
}
示例3: feathersExpress
import feathers, { Application } from '@feathersjs/feathers';
import feathersExpress, * as express from '@feathersjs/express';
const app = feathersExpress(feathers());
const feathersServiceDummy = {
get : () => {
return Promise.resolve({});
},
find : () => {
return Promise.resolve([{}, {}]);
}
};
const expressMiddlewareDummy = (req: express.Request, res: express.Response, next: express.NextFunction) => {
next();
return app;
};
app.use(express.json());
app.use(express.urlencoded({extended : true}));
app.use('/', express.static('./public'));
app.use('/', expressMiddlewareDummy, feathersServiceDummy);
app.configure(express.rest());
app.use(express.notFound());
app.use(express.errorHandler({logger : console}));
示例4: Error
if (!data.id) {
throw new Error('Data needs an id');
}
return data;
}
}
const port = 3000;
const app = express(feathers());
const auth = new AuthenticationService(app);
auth.register('jwt', new JWTStrategy());
auth.register('test', new TestOAuthStrategy());
app.configure(rest());
app.set('host', '127.0.0.1');
app.set('port', port);
app.set('authentication', {
secret: 'supersecret',
entity: 'user',
service: 'users',
authStrategies: [ 'jwt' ],
oauth: {
defaults: {
transport: 'query'
},
test: {
key: 'some-key',
secret: 'a secret secret'
},