Skip to content

Repository files navigation

ContributorsForksStargazersIssuesLicenseGitHub Build


Logo

@lithium/edge

A NestJS module to use EdgeJS templating language.

Request Feature · Report Bug · Request Modification

Table of Contents
  1. About The Project
  2. Install the package
  3. Use the package
  4. Utils links
  5. Contact

About the project

The Edge module is based on the idea of using EdgeJS templating within a NestJS application. The main problem with using EdgeJS within Nest comes from the resolution of Edge in ESM. In this case, we're using a workaround to make use of the dynamic import.

This module is built dynamically, allowing you to define a customized configuration for each use case. We recommend that you create a dedicated custom configuration file by importing a configuration object such as edge.config.ts.

We welcome contributions and improvements to this module. Don't hesitate to submit features and improvements ;)

(back to top)

Built With

  • TypeScript
  • NestJS
  • EdgeJS

(back to top)

Install the package

For now the package isn't published to npm, but you can install it from the GitHub registry and can be installed in any project.

  1. You need to create a .npmrc file at the root of your project with the following content:

    @lithium-apps:registry=https://npm.pkg.github.com
  2. For the login process you need to set a personal access token with the read:packages scope. Then you can login to the GitHub registry with the following command:

    pnpm login --registry=https://npm.pkg.github.com --scope=@lithium-apps
  3. You can now install the packages using the following command:

    pnpm install @lithium-apps/edge

(back to top)

Use the package

  1. Create a configuration file for Edge.JS :

    import{EdgeConfig}from'@lithium-apps/edge';exportconstedgeConfig: EdgeConfig={mount: {// Define all the named disk mount pointsviews: join(__dirname,'path_to_views'),},// You can set plugins hereplugins: [],// You can set globals hereglobals: {},// Check other options in the EdgeConfig interface};
  2. Import the EdgeModule in your application module:

    import{Module}from'@nestjs/common';import{EdgeModule}from'@lithium-apps/edge';import{edgeConfig}from'./edge.config';import{MyController}from'./my.controller';
    @Module({imports: [EdgeModule.forFeature(edgeConfig)],controllers: [MyController]})exportclassMyModule{}
  3. Use the @Render() decorator in your controller:

    import{Controller,Get}from'@nestjs/common';import{EdgeService}from'@lithium-apps/edge';
    @Controller()exportclassMyController{
    @Get('/')
    @Render('views::welcome')// Specify the view to renderasyncgetHello(){return{name: 'Kylian'};// Data to pass to the view}}

Useful links

Here are a few useful links to help you use the module or learn more about it! Don't thank us, you'll sleep better :)

Contact

(back to top)

About

A NestJS module to use Edge.JS templating language.

Topics

Resources

Contributing

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages