File tree Expand file tree Collapse file tree 9 files changed +22
-17
lines changed
Expand file tree Collapse file tree 9 files changed +22
-17
lines changed Original file line number Diff line number Diff line change 1010 "node/no-unpublished-import" : [" off" ],
1111 "node/no-unpublished-require" : [" off" ],
1212 "node/no-unsupported-features/es-syntax" : [" off" ]
13+ },
14+ "parserOptions" : {
15+ "sourceType" : " module"
1316 }
1417}
Original file line number Diff line number Diff line change @@ -28,12 +28,14 @@ export const buildRenderedHtml = async () => {
2828 const dirname = process . cwd ( ) ;
2929
3030 try {
31- markdownDefault = await fs . promises . readFile ( dirname + '/templates/markdown.md' ) ;
31+ markdownDefault = await fs . promises . readFile (
32+ dirname + '/templates/markdown.md'
33+ ) ;
3234 compiledTemplate = handlebars . compile (
3335 await fs . promises . readFile ( dirname + '/templates/index.html' , 'utf8' )
3436 ) ;
3537 renderedHtml = compiledTemplate ( { default : markdownDefault } ) ;
36-
38+
3739 return renderedHtml ;
3840 } catch ( err ) {
3941 throw Error ( 'Error loading template: ' , err ) ;
Original file line number Diff line number Diff line change 1313// limitations under the License.
1414
1515import app from './app.js' ;
16- import pkg from './package.json' assert { type : "json " } ;
16+ import fs from 'fs' ;
17+
18+ const pkg = JSON . parse ( fs . readFileSync ( './package.json' ) ) ;
1719
1820const PORT = parseInt ( process . env . PORT ) || 8080 ;
1921
Original file line number Diff line number Diff line change 1515// [START cloudrun_secure_request]
1616// [START run_secure_request]
1717
18- import { GoogleAuth } from 'google-auth-library' ;
18+ import { GoogleAuth } from 'google-auth-library' ;
1919import got from 'got' ;
2020
2121const auth = new GoogleAuth ( ) ;
@@ -37,8 +37,8 @@ const renderRequest = async markdown => {
3737 } ,
3838 body : markdown ,
3939 timeout : {
40- request : 10000
41- }
40+ request : 10000 ,
41+ } ,
4242 } ;
4343
4444 try {
Original file line number Diff line number Diff line change 1313// limitations under the License.
1414
1515import assert from 'assert' ;
16- import path from 'path' ;
1716import supertest from 'supertest' ;
17+ import { app , buildRenderedHtml } from '../app.js' ;
1818
1919describe ( 'Editor unit tests' , ( ) => {
2020 describe ( 'Initialize app' , ( ) => {
2121 it ( 'should successfully load the index page' , async ( ) => {
22- import { app } from path . join ( __dirname , '..' , 'app' ) ;
2322 const request = supertest ( app ) ;
2423 await request . get ( '/' ) . retry ( 3 ) . expect ( 200 ) ;
2524 } ) ;
@@ -29,7 +28,6 @@ describe('Editor unit tests', () => {
2928 let template ;
3029
3130 before ( async ( ) => {
32- import { buildRenderedHtml } from path . join ( __dirname , '..' , 'app' ) ;
3331 template = await buildRenderedHtml ( ) ;
3432 } ) ;
3533
@@ -46,7 +44,6 @@ describe('Integration tests', () => {
4644
4745 before ( async ( ) => {
4846 process . env . EDITOR_UPSTREAM_RENDER_URL = 'https://www.example.com/' ;
49- import { app } from path . join ( __dirname , '..' , 'app' ) ;
5047 request = supertest ( app ) ;
5148 } ) ;
5249
Original file line number Diff line number Diff line change 1414
1515import assert from 'assert' ;
1616import got from 'got' ;
17- import { execSync } from 'child_process' ;
18- import { GoogleAuth } from 'google-auth-library' ;
17+ import { execSync } from 'child_process' ;
18+ import { GoogleAuth } from 'google-auth-library' ;
1919
2020const auth = new GoogleAuth ( ) ;
2121
Original file line number Diff line number Diff line change 1313// limitations under the License.
1414
1515import app from './app.js' ;
16- import pkg from './package.json' assert { type : "json " } ;
16+ import fs from 'fs' ;
17+
18+ const pkg = JSON . parse ( fs . readFileSync ( './package.json' ) ) ;
1719
1820const PORT = parseInt ( process . env . PORT ) || 8080 ;
1921
Original file line number Diff line number Diff line change 1313// limitations under the License.
1414
1515import assert from 'assert' ;
16- import path from 'path' ;
1716import sinon from 'sinon' ;
1817import supertest from 'supertest' ;
18+ import { app } from '../app.js' ;
1919
2020let request ;
2121
2222describe ( 'Unit Tests' , ( ) => {
2323 before ( ( ) => {
24- import app from path . join ( __dirname , '..' , 'app' ) ;
2524 request = supertest ( app ) ;
2625 } ) ;
2726
Original file line number Diff line number Diff line change 1414
1515import assert from 'assert' ;
1616import got from 'got' ;
17- import { execSync } from 'child_process' ;
18- import { GoogleAuth } from 'google-auth-library' ;
17+ import { execSync } from 'child_process' ;
18+ import { GoogleAuth } from 'google-auth-library' ;
1919
2020const auth = new GoogleAuth ( ) ;
2121
You can’t perform that action at this time.
0 commit comments