-
Notifications
You must be signed in to change notification settings - Fork 56
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
1 parent
b71a251
commit a8ac30c
Showing
13 changed files
with
127 additions
and
4 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { Serializer } from 'jsonapi-serializer'; | ||
|
||
import { config } from '../../shared/config.js'; | ||
import { RedisClient } from '../../shared/infrastructure/utils/RedisClient.js'; | ||
|
||
const getInformationBanner = async function (request) { | ||
const target = request.path.target; | ||
|
||
const redisClient = new RedisClient(config.temporaryStorage.redisUrl, 'infrastructure'); | ||
const rawBanners = await redisClient.get(`information-banner:${target}`); | ||
const banners = JSON.parse(rawBanners); | ||
|
||
banners?.forEach((banner, index) => { | ||
banner.id = index + 1; | ||
}); | ||
|
||
const informationBanners = { | ||
id: target, | ||
banners, | ||
}; | ||
|
||
await redisClient.quit(); | ||
|
||
return new Serializer('information-banners', { | ||
attributes: ['banners'], | ||
banners: { | ||
included: true, | ||
ref: 'id', | ||
attributes: ['severity', 'message'], | ||
}, | ||
}).serialize(informationBanners); | ||
}; | ||
|
||
const bannerController = { | ||
getInformationBanner, | ||
}; | ||
|
||
export { bannerController }; |
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 { bannerController } from './banner-controller.js'; | ||
|
||
const register = async function (server) { | ||
server.route([ | ||
{ | ||
method: 'GET', | ||
path: '/api/information-banners/{target}', | ||
config: { | ||
auth: false, | ||
handler: bannerController.getInformationBanner, | ||
}, | ||
}, | ||
]); | ||
}; | ||
|
||
const name = 'src-banners-api'; | ||
export { name, register }; |
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,3 @@ | ||
import * as bannerRoute from './application/banner-route.js'; | ||
|
||
export const bannerRoutes = [bannerRoute]; |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import Model, { attr } from '@ember-data/model'; | ||
|
||
export default class InformationBanner extends Model { | ||
@attr() severity; | ||
@attr() message; | ||
} |
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,5 @@ | ||
import Model, { hasMany } from '@ember-data/model'; | ||
|
||
export default class InformationBanner extends Model { | ||
@hasMany('banners', { async: false, inverse: null }) banners; | ||
} |
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
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
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,7 @@ | ||
import { Factory } from 'miragejs'; | ||
|
||
export default Factory.extend({ | ||
banners() { | ||
return []; | ||
}, | ||
}); |
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