Expand my Community achievements bar.

Join us in celebrating the outstanding achievement of our AEM Community Member of the Year!
SOLVED

Basic NodeJS application creation and deploy to Adobe IO runtime

Avatar

Level 9

Hello team,

 

I am exploring Adobe IO runtime. I tried to create a simple rest API (as mentioned below) and I am able to hit the runtime using browser.

https://adobeioruntime.net/api/v1/web/12345-pocservice-dev/default/test?name=ABC

 

// this is saved in a file named first-function.js
function main(params) {
var nm = params.name || 'stranger';
return {
statusCode: 200,
body: {
payload: 'Hello ' + nm
}
}
}

exports.main = main;

 

Now, I need to write some NodeJS utility, which will have folders like: src, tests, config etc.

Now, sure about the way I need to create?  Help will be much appreciated here.

cc @sarav_prakash  @mk_aem21 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor
4 Replies

Avatar

Correct answer by
Community Advisor

Hi @Mahesh_Gunaje 

You can check smaple apps at https://developer.adobe.com/app-builder/docs/resources/sample_apps/ , if that helps



Arun Patidar

Avatar

Level 9

Thanks a lot @arunpatidar  for your quick help

Now, I have started referring to headless app

https://github.com/AdobeDocs/adobeio-codelabs-barcode

 

New to NodeJS, Adobe IO runtime.  Is there any documents related to best practices while setting up the project for the headless app in Adobe IO runtime? example: Nodejs version, folder, file structure etc ...

In the file: manifest.yml, I can see the sttement: runtime: 'nodejs:14'

Is this OK? Since, latest version is 22+. Also, in the runtime I can see NodeJS version: 18

 

Thanks

 

Avatar

Level 7

If you are new and just getting started, best advice would be to stick to ootb project template. When you run `aio app init myproject`, and choose Generic action template, boilerplate scaffold builds simple folder structure. 

 

Now production BE projects have a lot of folders for example. https://mr-alien.medium.com/folder-structure-for-nodejs-expressjs-project-56be9ec35548

 

If you are setting to just learn or running simple action doing small tasks, ignore complex folder structure. Keep it simple, under /actions, add all mjs files. And do refer to example projects as shared by Arun.