-
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.
Merge pull request #35 from namecheap/custom404Response
- Loading branch information
Showing
10 changed files
with
172 additions
and
102 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
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,9 @@ | ||
import * as types from '../types'; | ||
import { ServerResponse } from 'http'; | ||
import AppSdk from '../../app'; | ||
|
||
export interface ProcessedRequest<RegistryProps = unknown> { | ||
requestData: types.RequestData<RegistryProps>; | ||
appSdk: AppSdk; | ||
processResponse: (res: ServerResponse, data?: types.ResponseData) => void; | ||
} |
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,4 @@ | ||
export type SsrContext = { | ||
code?: number; | ||
headers?: Record<string, string>; | ||
}; |
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,2 @@ | ||
export * from './interfaces/ProcessedRequest'; | ||
export * from './interfaces/SsrContext'; |
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,35 @@ | ||
import IlcAppSdk from '../../src/app/index'; | ||
import { expect } from 'chai'; | ||
|
||
describe('IlcAppSdk', () => { | ||
it('should throw error due to not provided adapter', () => { | ||
// @ts-ignore | ||
expect(() => new IlcAppSdk()).to.throw('Unable to determine adapter properly...'); | ||
}); | ||
|
||
it('should render404 run trigger404Page method from adapter', () => { | ||
let page404Rendered = false; | ||
|
||
const appSdk = new IlcAppSdk({ | ||
appId: 'someAppId', | ||
intl: null, | ||
trigger404Page: () => { | ||
page404Rendered = true; | ||
}, | ||
}); | ||
|
||
expect(page404Rendered).to.be.false; | ||
appSdk.render404(); | ||
expect(page404Rendered).to.be.true; | ||
}); | ||
|
||
it('should "unmount" throw error due to not defined set method in adapter', () => { | ||
const appSdk = new IlcAppSdk({ | ||
appId: 'someAppId', | ||
intl: null, | ||
trigger404Page: () => {}, | ||
}); | ||
|
||
expect(() => appSdk.unmount()).to.throw("Looks like you're trying to call CSR only method during SSR"); | ||
}); | ||
}); |
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
Oops, something went wrong.