Development under this git repository is discontinued and future improvements will continue under io.hyperify.node.
Join our Discord to discuss about our software!
HG Backend module
This module depends on nodemailer, i18next and jws modules:
npm i '@types/i18next' i18next '@types/nodemailer' nodemailer '@types/jws' jwsOur fi.hg.core is also required dependency:
mkdir -p src/fi/hg
git submodule add git@github.com:heusalagroup/fi.hg.core.git src/fi/hg/core
git config -f .gitmodules submodule.src/fi/hg/core.branch mainFinally, you can set up the module itself:
git submodule add git@github.com:heusalagroup/fi.hg.backend.git src/fi/hg/backend
git config -f .gitmodules submodule.src/fi/hg/backend.branch mainSee also @heusalagroup/create-backend for how to initialize your own backend project.
You can use the EmailAuthController in your HTTP controller as follows:
class BackendController {
@PostMapping("/authenticateEmail")
public static async authenticateEmail (
@RequestBody
body: ReadonlyJsonObject,
@RequestParam(QueryParam.LANGUAGE, RequestParamValueType.STRING)
langString = ""
): Promise<ResponseEntity< EmailTokenDTO | ErrorDTO >> {
return EmailAuthController.authenticateEmail(body, langString);
}
@PostMapping("/verifyEmailToken")
public static async verifyEmailToken (
@RequestBody
body: ReadonlyJsonObject
): Promise<ResponseEntity<EmailTokenDTO | ErrorDTO>> {
return EmailAuthController.verifyEmailToken(body);
}
@PostMapping("/verifyEmailCode")
public static async verifyEmailCode (
@RequestBody
body: ReadonlyJsonObject
): Promise<ResponseEntity< EmailTokenDTO | ErrorDTO >> {
return EmailAuthController.verifyEmailCode(body);
}
}...and configure it in your main function:
async function main () {
EmailTokenService.setJwtEngine(
JwtService.createJwtEngine(
"secret-string",
"HS256" as Algorithm
)
);
EmailAuthController.setDefaultLanguage(Language.FINNISH);
await BackendTranslationService.initialize(Language.FINNISH, {
en: {
"common.hello": "hello world"
},
fi: {
"common.hello": "Moi maailma"
}
});
EmailService.initialize("smtp://localhost:25");
EmailService.setDefaultFrom("Example Inc <info@example.com>");
// .. other handling, see our backend creator tool
}See hg-email-auth for how to use the service.