1
1
import feathers from '@feathersjs/feathers' ;
2
- import '@feathersjs/transport-commons' ;
3
2
import express from '@feathersjs/express' ;
4
3
import socketio from '@feathersjs/socketio' ;
4
+ import '@feathersjs/transport-commons' ;
5
+
6
+ import services from './services' ;
5
7
6
- import { PollService } from './PollService' ;
7
- import { UserService } from "./UserService" ;
8
8
9
9
const app = express ( feathers ( ) ) ;
10
10
@@ -14,24 +14,10 @@ app.use(express.static(__dirname));
14
14
app . configure ( express . rest ( ) ) ;
15
15
app . configure ( socketio ( ) ) ;
16
16
app . use ( express . errorHandler ( ) ) ;
17
+ app . configure ( services ) ;
17
18
18
- app . use ( '/polls' , new PollService ( ) ) ;
19
- app . use ( '/users' , new UserService ( ) ) ;
20
-
21
- // Add any new real-time connection to the `everybody` channel
22
- app . on ( 'connection' , connection =>
23
- app . channel ( 'everybody' ) . join ( connection )
24
- ) ;
25
- // Publish all events to the `everybody` channel
26
- app . publish ( data => app . channel ( 'everybody' ) ) ;
27
19
28
-
29
- app . listen ( 3030 ) . on ( 'listening' , ( ) =>
30
- console . log ( 'Feathers server listening on localhost:3030' )
31
- ) ;
32
-
33
- // For good measure let's create a message
34
- // So our API doesn't look so empty
20
+ // Mock data
35
21
app . service ( 'polls' ) . create ( {
36
22
contents : {
37
23
left : {
@@ -51,3 +37,5 @@ app.service('users').create({
51
37
avatarUrl : 'https://github.com/ilyayudovin.png'
52
38
} ) ;
53
39
40
+ export default app ;
41
+
0 commit comments