Compare commits

..

9 Commits

Author SHA1 Message Date
standardci e0f2d5e202 chore(release): publish new version
- @standardnotes/api-gateway@1.3.0
2022-06-28 12:11:19 +00:00
Karol Sójko 3035cbc5de feat: remove api metadata decorating html responses 2022-06-28 14:10:40 +02:00
standardci 7c271be310 chore(release): publish new version
- @standardnotes/auth-server@1.3.3
2022-06-28 10:09:14 +00:00
Karol Sójko ba373ebc6b fix: change response type to html for muting marketing emails 2022-06-28 12:08:36 +02:00
Mo c50662849b Merge pull request #4 from standardnotes/chore/pr-workflow
chore: add pr workflow
2022-06-27 17:12:23 -05:00
Mo 82da690139 chore: add pr workflow 2022-06-27 17:04:39 -05:00
standardci b11a9b0eac chore(release): publish new version
- @standardnotes/auth-server@1.3.2
2022-06-27 22:02:46 +00:00
Mo d7653474c3 Merge pull request #3 from standardnotes/chore/upgrade-features
chore: upgrade features package
2022-06-27 17:01:41 -05:00
Mo ce2fd86ca3 chore: upgrade features package 2022-06-27 17:01:21 -05:00
11 changed files with 95 additions and 18 deletions
+21
View File
@@ -0,0 +1,21 @@
name: Pull Request
on:
pull_request:
branches:
- main
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install dependencies
run: yarn install
- name: ESLint
run: yarn lint
- name: Build
run: yarn build
- name: Test
run: yarn test
Generated
+10 -1
View File
@@ -2526,7 +2526,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
["@standardnotes/common", "npm:1.23.1"],\
["@standardnotes/domain-events", "npm:2.32.4"],\
["@standardnotes/domain-events-infra", "npm:1.5.2"],\
["@standardnotes/features", "npm:1.45.5"],\
["@standardnotes/features", "npm:1.46.0"],\
["@standardnotes/responses", "npm:1.6.36"],\
["@standardnotes/scheduler", "npm:1.1.1"],\
["@standardnotes/settings", "npm:1.15.0"],\
@@ -2702,6 +2702,15 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
["@standardnotes/common", "npm:1.23.1"]\
],\
"linkType": "HARD"\
}],\
["npm:1.46.0", {\
"packageLocation": "./.yarn/cache/@standardnotes-features-npm-1.46.0-32e559e3b6-0653b9b425.zip/node_modules/@standardnotes/features/",\
"packageDependencies": [\
["@standardnotes/features", "npm:1.46.0"],\
["@standardnotes/auth", "npm:3.19.4"],\
["@standardnotes/common", "npm:1.23.1"]\
],\
"linkType": "HARD"\
}]\
]],\
["@standardnotes/files-server", [\
+6
View File
@@ -3,6 +3,12 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [1.3.0](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.2.2...@standardnotes/api-gateway@1.3.0) (2022-06-28)
### Features
* remove api metadata decorating html responses ([3035cbc](https://github.com/standardnotes/api-gateway/commit/3035cbc5ded1408bc4b8646563c4992ba5f27c75))
## [1.2.2](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.2.1...@standardnotes/api-gateway@1.2.2) (2022-06-27)
**Note:** Version bump only for package @standardnotes/api-gateway
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@standardnotes/api-gateway",
"version": "1.2.2",
"version": "1.3.0",
"engines": {
"node": ">=16.0.0 <17.0.0"
},
@@ -162,6 +162,12 @@ export class HttpService implements HttpServiceInterface {
this.applyResponseHeaders(serviceResponse, response)
if (this.responseShouldNotBeDecorated(serviceResponse)) {
response.status(serviceResponse.status).send(serviceResponse.data)
return
}
response.status(serviceResponse.status).send({
meta: {
auth: {
@@ -213,6 +219,10 @@ export class HttpService implements HttpServiceInterface {
return payload
}
private responseShouldNotBeDecorated(serviceResponse: AxiosResponse): boolean {
return serviceResponse.headers['content-type'].toLowerCase().includes('text/html')
}
private applyResponseHeaders(serviceResponse: AxiosResponse, response: Response): void {
const returnedHeadersFromUnderlyingService = [
'access-control-allow-methods',
+10
View File
@@ -3,6 +3,16 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.3.3](https://github.com/standardnotes/auth/compare/@standardnotes/auth-server@1.3.2...@standardnotes/auth-server@1.3.3) (2022-06-28)
### Bug Fixes
* change response type to html for muting marketing emails ([ba373eb](https://github.com/standardnotes/auth/commit/ba373ebc6b3038f7de2fab40f0429a655dbe2499))
## [1.3.2](https://github.com/standardnotes/auth/compare/@standardnotes/auth-server@1.3.1...@standardnotes/auth-server@1.3.2) (2022-06-27)
**Note:** Version bump only for package @standardnotes/auth-server
## [1.3.1](https://github.com/standardnotes/auth/compare/@standardnotes/auth-server@1.3.0...@standardnotes/auth-server@1.3.1) (2022-06-27)
**Note:** Version bump only for package @standardnotes/auth-server
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "@standardnotes/auth-server",
"version": "1.3.1",
"version": "1.3.3",
"engines": {
"node": ">=16.0.0 <17.0.0"
},
@@ -38,7 +38,7 @@
"@standardnotes/common": "^1.23.1",
"@standardnotes/domain-events": "^2.32.4",
"@standardnotes/domain-events-infra": "^1.4.135",
"@standardnotes/features": "^1.45.2",
"@standardnotes/features": "^1.46.0",
"@standardnotes/responses": "^1.6.15",
"@standardnotes/scheduler": "^1.1.1",
"@standardnotes/settings": "^1.15.0",
@@ -19,6 +19,7 @@ describe('InternalController', () => {
let muteMarketingEmails: MuteMarketingEmails
let request: express.Request
let response: express.Response
let user: User
const createController = () =>
@@ -48,6 +49,11 @@ describe('InternalController', () => {
body: {},
params: {},
} as jest.Mocked<express.Request>
response = {} as jest.Mocked<express.Response>
response.setHeader = jest.fn()
response.status = jest.fn().mockReturnThis()
response.send = jest.fn()
})
it('should get user features', async () => {
@@ -170,26 +176,27 @@ describe('InternalController', () => {
it('should mute marketing emails user setting', async () => {
request.params.settingUuid = '1-2-3'
muteMarketingEmails.execute = jest.fn().mockReturnValue({ success: true })
muteMarketingEmails.execute = jest.fn().mockReturnValue({ success: true, message: 'foobar' })
const httpResponse = <results.JsonResult>await createController().muteMarketingEmails(request)
const result = await httpResponse.executeAsync()
await createController().muteMarketingEmails(request, response)
expect(muteMarketingEmails.execute).toHaveBeenCalledWith({ settingUuid: '1-2-3' })
expect(result.statusCode).toEqual(200)
expect(response.setHeader).toHaveBeenCalledWith('content-type', 'text/html')
expect(response.send).toHaveBeenCalledWith('foobar')
})
it('should not mute marketing emails user setting if it does not exist', async () => {
request.params.settingUuid = '1-2-3'
muteMarketingEmails.execute = jest.fn().mockReturnValue({ success: false })
muteMarketingEmails.execute = jest.fn().mockReturnValue({ success: false, message: 'foobar' })
const httpResponse = <results.JsonResult>await createController().muteMarketingEmails(request)
const result = await httpResponse.executeAsync()
await createController().muteMarketingEmails(request, response)
expect(muteMarketingEmails.execute).toHaveBeenCalledWith({ settingUuid: '1-2-3' })
expect(result.statusCode).toEqual(404)
expect(response.setHeader).toHaveBeenCalledWith('content-type', 'text/html')
expect(response.status).toHaveBeenCalledWith(404)
expect(response.send).toHaveBeenCalledWith('foobar')
})
})
@@ -1,4 +1,4 @@
import { Request } from 'express'
import { Request, Response } from 'express'
import { inject } from 'inversify'
import {
BaseHttpController,
@@ -84,16 +84,20 @@ export class InternalController extends BaseHttpController {
}
@httpGet('/settings/marketing-emails/:settingUuid/mute')
async muteMarketingEmails(request: Request): Promise<results.JsonResult> {
async muteMarketingEmails(request: Request, response: Response): Promise<void> {
const { settingUuid } = request.params
const result = await this.doMuteMarketingEmails.execute({
settingUuid,
})
response.setHeader('content-type', 'text/html')
if (result.success) {
return this.json({ message: result.message })
response.send(result.message)
return
}
return this.json({ message: result.message }, 404)
response.status(404).send(result.message)
}
}
+12 -2
View File
@@ -1824,7 +1824,7 @@ __metadata:
"@standardnotes/common": ^1.23.1
"@standardnotes/domain-events": ^2.32.4
"@standardnotes/domain-events-infra": ^1.4.135
"@standardnotes/features": ^1.45.2
"@standardnotes/features": ^1.46.0
"@standardnotes/responses": ^1.6.15
"@standardnotes/scheduler": ^1.1.1
"@standardnotes/settings": ^1.15.0
@@ -2009,7 +2009,7 @@ __metadata:
languageName: node
linkType: hard
"@standardnotes/features@npm:^1.36.3, @standardnotes/features@npm:^1.44.6, @standardnotes/features@npm:^1.45.2, @standardnotes/features@npm:^1.45.5":
"@standardnotes/features@npm:^1.36.3, @standardnotes/features@npm:^1.44.6, @standardnotes/features@npm:^1.45.5":
version: 1.45.5
resolution: "@standardnotes/features@npm:1.45.5"
dependencies:
@@ -2029,6 +2029,16 @@ __metadata:
languageName: node
linkType: hard
"@standardnotes/features@npm:^1.46.0":
version: 1.46.0
resolution: "@standardnotes/features@npm:1.46.0"
dependencies:
"@standardnotes/auth": ^3.19.4
"@standardnotes/common": ^1.23.1
checksum: 0653b9b425e86cf0f2e6a80fb68316c841aaf7feb23ca39131e3d09546735d199879532ef9e89f424000b916dd5ac2d7e6ea0e60ac755712ef37c3fecdf48d94
languageName: node
linkType: hard
"@standardnotes/files-server@workspace:packages/files":
version: 0.0.0-use.local
resolution: "@standardnotes/files-server@workspace:packages/files"