node.js

Share common typescript code across node projects

自作多情 提交于 2021-02-08 15:19:18
问题 Assuming I have the following project structure: webapps ProjectA SomeClass.ts Package.json ProjectB SomeClass.ts Package.json Common LoggingClass.ts Package.json The Common "LoggingClass" need to import a module from NPM. Let's assume that module is UUID (https://www.npmjs.com/package/uuid) The problem, or the challenge is the following: We want to use and import the "LoggingClass" in both ProjectA and ProjectB. Thing is, they can import the code from the common folder without a problem, but

How to return a 404 HTTP status code when promise resolve to undefined in Nest?

折月煮酒 提交于 2021-02-08 15:13:45
问题 In order to avoid boilerplate code (checking for undefined in every controller, over and over again), how can I automatically return a 404 error when the promise in getOne returns undefined? @Controller('/customers') export class CustomerController { constructor ( @InjectRepository(Customer) private readonly repository: Repository<Customer> ) { } @Get('/:id') async getOne(@Param('id') id): Promise<Customer|undefined> { return this.repository.findOne(id) .then(result => { if (typeof result ===

fs.existsSync is not a function when used in electron

烈酒焚心 提交于 2021-02-08 15:12:46
问题 I am using Angular 10 , Electron 10.0 and electron-builder v22.8.0 . When starting my Electron app, I receive the following error in the console: fs.existsSync is not a function when used in electron getElectronPath @ ./node_modules/events/events.js:6 <anonymous> @ ./node_modules/events/events.js:17 ./node_modules/electron/index.js @ ./node_modules/events/events.js:19 __webpack_require__ @ ./webpack/bootstrap:79 ./src/app/projectview/new/new.component.ts @ ./src/app/projectview/new/new

How to return a 404 HTTP status code when promise resolve to undefined in Nest?

纵饮孤独 提交于 2021-02-08 15:12:21
问题 In order to avoid boilerplate code (checking for undefined in every controller, over and over again), how can I automatically return a 404 error when the promise in getOne returns undefined? @Controller('/customers') export class CustomerController { constructor ( @InjectRepository(Customer) private readonly repository: Repository<Customer> ) { } @Get('/:id') async getOne(@Param('id') id): Promise<Customer|undefined> { return this.repository.findOne(id) .then(result => { if (typeof result ===

“[SyntaxError: Unexpected token <]” when I try to add documents to my Solr index with my Node/Express app

强颜欢笑 提交于 2021-02-08 15:11:33
问题 I'm trying to integrate Solr into a Node/Express app and while I am using this Node package for the Solr integration. I am able to properly query the index, but following the instructions on the package's GitHub, I am unable to add documents to the index. I keep getting this error: [SyntaxError: Unexpected token <] On the Solr console, the error is a little more detailed: SEVERE: Error processing "legacy" update command:com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character '['

fs.existsSync is not a function when used in electron

瘦欲@ 提交于 2021-02-08 15:11:18
问题 I am using Angular 10 , Electron 10.0 and electron-builder v22.8.0 . When starting my Electron app, I receive the following error in the console: fs.existsSync is not a function when used in electron getElectronPath @ ./node_modules/events/events.js:6 <anonymous> @ ./node_modules/events/events.js:17 ./node_modules/electron/index.js @ ./node_modules/events/events.js:19 __webpack_require__ @ ./webpack/bootstrap:79 ./src/app/projectview/new/new.component.ts @ ./src/app/projectview/new/new

Module not found: Error: Can't resolve 'openlayers' using TypeScript definition file

喜欢而已 提交于 2021-02-08 15:11:00
问题 In a Visual Studio 2017 React application using TypeScrpt there is a component (Map.tsx) that utilizes OpenLayers v4.6.5. The package.json file loads both the @types/openlayers and the "ol" module. { "name": "mhc-maps", "private": true, "version": "2.0.0", "devDependencies": { "@types/history": "^4.6.2", "@types/jquery": "^3.3.1", "@types/openlayers": "^4.6.9", "@types/react": "^16.3.5", "@types/react-dom": "^16.0.4", "@types/react-hot-loader": "^3.0.6", "@types/react-router": "^4.0.23", "

Module not found: Error: Can't resolve 'openlayers' using TypeScript definition file

爷,独闯天下 提交于 2021-02-08 15:10:33
问题 In a Visual Studio 2017 React application using TypeScrpt there is a component (Map.tsx) that utilizes OpenLayers v4.6.5. The package.json file loads both the @types/openlayers and the "ol" module. { "name": "mhc-maps", "private": true, "version": "2.0.0", "devDependencies": { "@types/history": "^4.6.2", "@types/jquery": "^3.3.1", "@types/openlayers": "^4.6.9", "@types/react": "^16.3.5", "@types/react-dom": "^16.0.4", "@types/react-hot-loader": "^3.0.6", "@types/react-router": "^4.0.23", "

Module not found: Error: Can't resolve 'openlayers' using TypeScript definition file

柔情痞子 提交于 2021-02-08 15:10:12
问题 In a Visual Studio 2017 React application using TypeScrpt there is a component (Map.tsx) that utilizes OpenLayers v4.6.5. The package.json file loads both the @types/openlayers and the "ol" module. { "name": "mhc-maps", "private": true, "version": "2.0.0", "devDependencies": { "@types/history": "^4.6.2", "@types/jquery": "^3.3.1", "@types/openlayers": "^4.6.9", "@types/react": "^16.3.5", "@types/react-dom": "^16.0.4", "@types/react-hot-loader": "^3.0.6", "@types/react-router": "^4.0.23", "

“[SyntaxError: Unexpected token <]” when I try to add documents to my Solr index with my Node/Express app

自古美人都是妖i 提交于 2021-02-08 15:06:43
问题 I'm trying to integrate Solr into a Node/Express app and while I am using this Node package for the Solr integration. I am able to properly query the index, but following the instructions on the package's GitHub, I am unable to add documents to the index. I keep getting this error: [SyntaxError: Unexpected token <] On the Solr console, the error is a little more detailed: SEVERE: Error processing "legacy" update command:com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character '['