This repository has been archived by the owner on May 19, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
166 additions
and
2 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
import { Application as ExpressFeathers } from '@feathersjs/express' | ||
import { StorageOffer } from './services/storage-offer/storage-offer.service' | ||
import { ServiceAddons } from '@feathersjs/feathers' | ||
|
||
// A mapping of service names to types. Will be extended in service files. | ||
export type ServiceTypes = {} | ||
|
||
interface ServiceTypes { | ||
'storage-offer': StorageOffer & ServiceAddons<any> | ||
} | ||
// The application instance type that will be used everywhere else | ||
export type Application = ExpressFeathers<ServiceTypes>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Table, DataType, Column, Model, ForeignKey, BelongsTo } from 'sequelize-typescript' | ||
import StorageOffer from './storage-offer.model' | ||
|
||
@Table | ||
export default class Price extends Model { | ||
@Column | ||
period!: number | ||
|
||
@Column | ||
amount!: number | ||
|
||
@ForeignKey(() => StorageOffer) | ||
@Column | ||
offerId!: number | ||
|
||
@BelongsTo(() => StorageOffer) | ||
offer!: StorageOffer | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { Table, DataType, Column, Model, HasMany } from 'sequelize-typescript' | ||
import Price from './price.model' | ||
|
||
@Table | ||
export default class StorageOffer extends Model { | ||
@Column | ||
capacity!: number | ||
|
||
@Column | ||
maximumDuration!: number | ||
|
||
@Column | ||
address!: string | ||
|
||
@HasMany(() => Price) | ||
prices!: Price[] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
import { Application } from '../declarations' | ||
import storageOffer from './storage-offer/storage-offer.service' | ||
// Don't remove this comment. It's needed to format import lines nicely. | ||
|
||
export default function (app: Application) { | ||
app.configure(storageOffer) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { disallow } from 'feathers-hooks-common' | ||
|
||
export default { | ||
before: { | ||
all: [], | ||
find: [], | ||
get: [], | ||
create: disallow(), | ||
update: disallow(), | ||
patch: disallow(), | ||
remove: disallow() | ||
}, | ||
|
||
after: { | ||
all: [], | ||
find: [], | ||
get: [], | ||
create: [], | ||
update: [], | ||
patch: [], | ||
remove: [] | ||
}, | ||
|
||
error: { | ||
all: [], | ||
find: [], | ||
get: [], | ||
create: [], | ||
update: [], | ||
patch: [], | ||
remove: [] | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Initializes the `StorageOffer` service on path `/storage-offer` | ||
import StorageOffer from '../../models/storage-offer.model' | ||
import hooks from './storage-offer.hooks' | ||
import { Service, SequelizeServiceOptions } from 'feathers-sequelize' | ||
import { Application } from '../../declarations' | ||
|
||
export class StorageOfferService extends Service { | ||
constructor (options: Partial<SequelizeServiceOptions>, app: Application) { | ||
super(options) | ||
} | ||
} | ||
|
||
export default function (app: Application) { | ||
const options = { | ||
Model: StorageOffer | ||
// Can't be used atm because of https://github.com/sequelize/sequelize/issues/11894 | ||
// paginate: app.get('paginate') | ||
} | ||
|
||
// Initialize our service with any options it requires | ||
app.use('/storage-offer', new StorageOfferService(options, app)) | ||
|
||
// Get our initialized service so that we can register hooks | ||
const service = app.service('storage-offer') | ||
|
||
service.hooks(hooks) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import assert from 'assert'; | ||
import app from '../../src/app'; | ||
|
||
describe('\'StorageOffer\' service', () => { | ||
it('registered the service', () => { | ||
const service = app.service('storage-offer'); | ||
|
||
assert.ok(service, 'Registered the service'); | ||
}); | ||
}); |