diff --git a/hello/README.md b/hello/README.md new file mode 100644 index 00000000..eb999210 --- /dev/null +++ b/hello/README.md @@ -0,0 +1,15 @@ +# Hello World Getting Started Sample + +## Next Steps + +- To run the JavaScript implementation, open a new terminal and run `cds watch`. +- To run the TypeScript implementation, open a new terminal and run `cds-ts watch`. + +Then call the service at: http://localhost:4004/say/hello(to='world') + +## Learn More + +Learn more about: + +- [Hello World!](https://cap.cloud.sap/docs/get-started/hello-world) +- [Using TypeScript](https://cap.cloud.sap/docs/get-started/using-typescript) \ No newline at end of file diff --git a/hello/package.json b/hello/package.json index deafc5e0..df8fdddb 100644 --- a/hello/package.json +++ b/hello/package.json @@ -3,8 +3,8 @@ "version": "1.0.0", "scripts": { "test": "npx jest --silent", - "watch": "cds serve world.cds", - "watch:ts": "cds-ts serve world.cds" + "start": "cds serve srv/world.cds", + "start:ts": "cds-ts serve srv/world.cds" }, "devDependencies": { "@types/jest": "^26.0.23", @@ -25,5 +25,30 @@ } } } + }, + "eslintConfig": { + "extends": "eslint:recommended", + "env": { + "es2020": true, + "node": true, + "jest": true, + "mocha": true + }, + "globals": { + "SELECT": true, + "INSERT": true, + "UPDATE": true, + "DELETE": true, + "CREATE": true, + "DROP": true, + "CDL": true, + "CQL": true, + "CXL": true, + "cds": true + }, + "rules": { + "no-console": "off", + "require-atomic-updates": "off" + } } } diff --git a/hello/world.cds b/hello/srv/world.cds similarity index 100% rename from hello/world.cds rename to hello/srv/world.cds diff --git a/hello/world.js b/hello/srv/world.js similarity index 100% rename from hello/world.js rename to hello/srv/world.js diff --git a/hello/srv/world.ts b/hello/srv/world.ts new file mode 100644 index 00000000..21a63b46 --- /dev/null +++ b/hello/srv/world.ts @@ -0,0 +1,5 @@ +module.exports = class say { + hello(req: any) { + return `Hello ${req.data.to} from a TypeScript file!` + } +} diff --git a/hello/test/hello-world-ts.test.ts b/hello/test/hello-world-ts.test.ts index 02a8df88..9376fca3 100644 --- a/hello/test/hello-world-ts.test.ts +++ b/hello/test/hello-world-ts.test.ts @@ -2,7 +2,7 @@ process.env.CDS_TYPESCRIPT = 'true'; import * as cds from '@sap/cds'; //@ts-ignore -const {GET} = cds.test.in(__dirname,'..').run('serve', 'world.cds'); +const {GET} = cds.test.in(__dirname,'../srv').run('serve', 'world.cds'); describe('Hello world!', () => { afterAll(() => { delete process.env.CDS_TYPESCRIPT; }); diff --git a/hello/world.ts b/hello/world.ts deleted file mode 100644 index 956946ac..00000000 --- a/hello/world.ts +++ /dev/null @@ -1,5 +0,0 @@ -module.exports = class say { - hello(req: any) { - return `Hello ${req.data.to} from a typescript file!` - } -} diff --git a/package.json b/package.json index d796f30b..14e5e2b1 100644 --- a/package.json +++ b/package.json @@ -27,6 +27,7 @@ "registry": "node .registry/server.js", "bookshop": "cds watch bookshop", "fiori": "cds watch fiori", + "hello": "cds watch hello", "media": "cds watch media", "mocha": "npx mocha || echo", "jest": "npx jest", diff --git a/test/hello-world.test.js b/test/hello-world.test.js index d833dce3..346b295f 100644 --- a/test/hello-world.test.js +++ b/test/hello-world.test.js @@ -1,4 +1,4 @@ -const { GET, expect } = require('../test') .run ('serve','hello/world.cds') +const { GET, expect } = require('../test') .run ('serve','hello/srv/world.cds') describe('Hello world!', () => {