diff options
author | Eugene Sokolov <eug-vs@keemail.me> | 2020-06-09 14:26:22 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-09 14:26:22 +0300 |
commit | bd36aeb53d04a13167925ecd4d5d73ed2ad09914 (patch) | |
tree | 5bc0a1e78cf72c6e1ae48f5ee3954511748c81b1 /app.ts | |
parent | abe7c3220c40031b9adecf9b27ab7141b7d3f736 (diff) | |
parent | e9d0438f6c02664c652a593c686564361fa0de6b (diff) | |
download | which-api-bd36aeb53d04a13167925ecd4d5d73ed2ad09914.tar.gz |
Merge pull request #2 from eug-vs/refactor
Structurize feathers app
Diffstat (limited to 'app.ts')
-rw-r--r-- | app.ts | 32 |
1 files changed, 9 insertions, 23 deletions
@@ -1,10 +1,10 @@ import feathers from '@feathersjs/feathers'; -import '@feathersjs/transport-commons'; import express from '@feathersjs/express'; import socketio from '@feathersjs/socketio'; +import '@feathersjs/transport-commons'; + +import services from './services'; -import { PollService } from './PollService'; -import {UserService} from "./UserService"; const app = express(feathers()); @@ -14,24 +14,10 @@ app.use(express.static(__dirname)); app.configure(express.rest()); app.configure(socketio()); app.use(express.errorHandler()); - -app.use('/polls', new PollService()); -app.use('/users', new UserService()); - -// Add any new real-time connection to the `everybody` channel -app.on('connection', connection => - app.channel('everybody').join(connection) -); -// Publish all events to the `everybody` channel -app.publish(data => app.channel('everybody')); +app.configure(services); -app.listen(3030).on('listening', () => - console.log('Feathers server listening on localhost:3030') -); - -// For good measure let's create a message -// So our API doesn't look so empty +// Mock data app.service('polls').create({ contents: { left: { @@ -46,10 +32,10 @@ app.service('polls').create({ }); app.service('users').create({ - info: { name: 'John Doe', age: 20, - nationality: 'Belarus', - sex: 'male' - } + avatarUrl: 'https://github.com/ilyayudovin.png' }); + +export default app; + |