Separate services and routes into features
This commit is contained in:
parent
2ed3aeac26
commit
2b431bee78
@ -1,5 +1,10 @@
|
||||
import * as comment from '../comment'
|
||||
import * as middleware from '../middleware'
|
||||
import * as routes from '../routes'
|
||||
import * as services from '../services'
|
||||
import * as site from '../site'
|
||||
import * as story from '../story'
|
||||
import * as team from '../team'
|
||||
import express from 'express'
|
||||
import {AsyncRouter, TransactionalRouter} from '../router'
|
||||
import {IApplication} from './IApplication'
|
||||
@ -8,7 +13,6 @@ import {IDatabase} from '../database/IDatabase'
|
||||
import {ILogger} from '../logger/ILogger'
|
||||
import {IRoutes} from '@rondo/common'
|
||||
import {ITransactionManager} from '../database/ITransactionManager'
|
||||
import * as services from '../services'
|
||||
import {loggerFactory, LoggerFactory} from '../logger/LoggerFactory'
|
||||
import {urlencoded, json} from 'body-parser'
|
||||
|
||||
@ -17,10 +21,10 @@ export class Application implements IApplication {
|
||||
readonly server: express.Application
|
||||
|
||||
readonly userService: services.IUserService
|
||||
readonly teamService: services.ITeamService
|
||||
readonly siteService: services.ISiteService
|
||||
readonly storyService: services.IStoryService
|
||||
readonly commentService: services.ICommentService
|
||||
readonly teamService: team.ITeamService
|
||||
readonly siteService: site.ISiteService
|
||||
readonly storyService: story.IStoryService
|
||||
readonly commentService: comment.ICommentService
|
||||
|
||||
readonly authenticator: middleware.Authenticator
|
||||
|
||||
@ -30,11 +34,11 @@ export class Application implements IApplication {
|
||||
this.transactionManager = database.transactionManager
|
||||
this.userService = new services.UserService(this.transactionManager)
|
||||
|
||||
this.teamService = new services.TeamService(this.transactionManager)
|
||||
this.siteService = new services.SiteService(this.transactionManager)
|
||||
this.storyService = new services.StoryService(
|
||||
this.teamService = new team.TeamService(this.transactionManager)
|
||||
this.siteService = new site.SiteService(this.transactionManager)
|
||||
this.storyService = new story.StoryService(
|
||||
this.transactionManager, this.siteService)
|
||||
this.commentService = new services.CommentService(this.transactionManager)
|
||||
this.commentService = new comment.CommentService(this.transactionManager)
|
||||
|
||||
this.authenticator = new middleware.Authenticator(this.userService)
|
||||
|
||||
@ -96,22 +100,22 @@ export class Application implements IApplication {
|
||||
this.createTransactionalRouter(),
|
||||
).handle)
|
||||
|
||||
router.use('/api', new routes.TeamRoutes(
|
||||
router.use('/api', new team.TeamRoutes(
|
||||
this.teamService,
|
||||
this.createTransactionalRouter(),
|
||||
).handle)
|
||||
|
||||
router.use('/api', new routes.SiteRoutes(
|
||||
router.use('/api', new site.SiteRoutes(
|
||||
this.siteService,
|
||||
this.createTransactionalRouter(),
|
||||
).handle)
|
||||
|
||||
router.use('/api', new routes.StoryRoutes(
|
||||
router.use('/api', new story.StoryRoutes(
|
||||
this.storyService,
|
||||
this.createTransactionalRouter(),
|
||||
).handle)
|
||||
|
||||
router.use('/api', new routes.CommentRoutes(
|
||||
router.use('/api', new comment.CommentRoutes(
|
||||
this.commentService,
|
||||
this.createTransactionalRouter(),
|
||||
).handle)
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import {AsyncRouter} from '../router'
|
||||
import {BaseRoute} from './BaseRoute'
|
||||
import {BaseRoute} from '../routes/BaseRoute'
|
||||
import {IAPIDef} from '@rondo/common'
|
||||
import {ICommentService} from '../services/ICommentService'
|
||||
import {ICommentService} from './ICommentService'
|
||||
import {ensureLoggedInApi} from '../middleware'
|
||||
|
||||
export class CommentRoutes extends BaseRoute<IAPIDef> {
|
||||
@ -1,4 +1,4 @@
|
||||
import {BaseService} from './BaseService'
|
||||
import {BaseService} from '../services/BaseService'
|
||||
import {Comment} from '../entities/Comment'
|
||||
import {ICommentService} from './ICommentService'
|
||||
import {IComment, ICommentTree} from '@rondo/common'
|
||||
3
packages/server/src/comment/index.ts
Normal file
3
packages/server/src/comment/index.ts
Normal file
@ -0,0 +1,3 @@
|
||||
export * from './CommentRoutes'
|
||||
export * from './CommentService'
|
||||
export * from './ICommentService'
|
||||
@ -1,8 +1,4 @@
|
||||
export * from './BaseRoute'
|
||||
export * from './CommentRoutes'
|
||||
export * from './LoginRoutes'
|
||||
export * from './SiteRoutes'
|
||||
export * from './StoryRoutes'
|
||||
export * from './TeamRoutes'
|
||||
export * from './UserRoutes'
|
||||
export * from './application'
|
||||
|
||||
@ -1,10 +1,2 @@
|
||||
export * from './CommentService'
|
||||
export * from './ICommentService'
|
||||
export * from './ISiteService'
|
||||
export * from './IStoryService'
|
||||
export * from './ITeamService'
|
||||
export * from './IUserService'
|
||||
export * from './SiteService'
|
||||
export * from './StoryService'
|
||||
export * from './TeamService'
|
||||
export * from './UserService'
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import {AsyncRouter} from '../router'
|
||||
import {BaseRoute} from './BaseRoute'
|
||||
import {BaseRoute} from '../routes/BaseRoute'
|
||||
import {IAPIDef} from '@rondo/common'
|
||||
import {ISiteService} from '../services/ISiteService'
|
||||
import {ISiteService} from './ISiteService'
|
||||
import {ensureLoggedInApi} from '../middleware'
|
||||
|
||||
export class SiteRoutes extends BaseRoute<IAPIDef> {
|
||||
@ -1,4 +1,4 @@
|
||||
import {BaseService} from './BaseService'
|
||||
import {BaseService} from '../services/BaseService'
|
||||
import {ISiteService} from './ISiteService'
|
||||
import {Site} from '../entities/Site'
|
||||
|
||||
3
packages/server/src/site/index.ts
Normal file
3
packages/server/src/site/index.ts
Normal file
@ -0,0 +1,3 @@
|
||||
export * from './ISiteService'
|
||||
export * from './SiteRoutes'
|
||||
export * from './SiteService'
|
||||
@ -1,7 +1,7 @@
|
||||
import {AsyncRouter} from '../router'
|
||||
import {BaseRoute} from './BaseRoute'
|
||||
import {BaseRoute} from '../routes/BaseRoute'
|
||||
import {IAPIDef} from '@rondo/common'
|
||||
import {IStoryService} from '../services/IStoryService'
|
||||
import {IStoryService} from './IStoryService'
|
||||
|
||||
export class StoryRoutes extends BaseRoute<IAPIDef> {
|
||||
constructor(
|
||||
@ -1,6 +1,6 @@
|
||||
import URL from 'url'
|
||||
import {BaseService} from './BaseService'
|
||||
import {ISiteService} from './ISiteService'
|
||||
import {BaseService} from '../services/BaseService'
|
||||
import {ISiteService} from '../site/ISiteService'
|
||||
import {IStoryService} from './IStoryService'
|
||||
import {ITransactionManager} from '../database/ITransactionManager'
|
||||
import {Story} from '../entities/Story'
|
||||
3
packages/server/src/story/index.ts
Normal file
3
packages/server/src/story/index.ts
Normal file
@ -0,0 +1,3 @@
|
||||
export * from './StoryRoutes'
|
||||
export * from './IStoryService'
|
||||
export * from './StoryService'
|
||||
@ -1,7 +1,7 @@
|
||||
import {AsyncRouter} from '../router'
|
||||
import {BaseRoute} from './BaseRoute'
|
||||
import {BaseRoute} from '../routes/BaseRoute'
|
||||
import {IAPIDef} from '@rondo/common'
|
||||
import {ITeamService} from '../services/ITeamService'
|
||||
import {ITeamService} from './ITeamService'
|
||||
import {ensureLoggedInApi} from '../middleware'
|
||||
|
||||
export class TeamRoutes extends BaseRoute<IAPIDef> {
|
||||
@ -1,4 +1,4 @@
|
||||
import {BaseService} from './BaseService'
|
||||
import {BaseService} from '../services/BaseService'
|
||||
import {ITeamService} from './ITeamService'
|
||||
import {Team} from '../entities/Team'
|
||||
|
||||
3
packages/server/src/team/index.ts
Normal file
3
packages/server/src/team/index.ts
Normal file
@ -0,0 +1,3 @@
|
||||
export * from './ITeamService'
|
||||
export * from './TeamRoutes'
|
||||
export * from './TeamService'
|
||||
Loading…
x
Reference in New Issue
Block a user