File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- import { IMain , IDatabase , IOptions } from 'pg-promise' ;
2- import { dwConfig } from './config' ;
1+ import { IDatabase , IMain , IOptions } from 'pg-promise' ;
2+ import { dwConfig } from './config' ;
33import * as pgPromise from 'pg-promise' ;
4- import { writeKeyToCacheFile } from '../cache' ;
4+ import { writeKeyToCacheFile } from '../cache' ;
55import * as LRU from 'lru-cache' ;
66
77export interface IExtensions {
@@ -26,14 +26,15 @@ const options: IOptions<IExtensions> = {
2626 return Promise . resolve ( dbCache . get ( getQuery ) ) ;
2727 }
2828 // TODO: cross check
29- if ( process . env . NODE_ENV === 'development' ) writeKeyToCacheFile ( getQuery , 'dw' ) ; // should be an option
29+ if ( process . env . NODE_ENV === 'development' ) { writeKeyToCacheFile ( getQuery , 'dw' ) ; } // should be an option
30+
3031 return obj . any ( getQuery ) ;
3132 } ;
3233 } ,
3334 // caching
3435 receive : ( data , _result , event ) => {
3536 // cache recieved
36- if ( ! dbCache . has ( event . query ) ) dbCache . set ( event . query , data ) ;
37+ if ( ! dbCache . has ( event . query ) ) { dbCache . set ( event . query , data ) ; }
3738 }
3839} ;
3940
Original file line number Diff line number Diff line change @@ -35,10 +35,13 @@ export interface IRegional extends IEntityBasic {
3535export const getEntities = ( ) : Promise < IEntity [ ] > => githubGet < IEntity > ( 'global/entity.csv' ) ;
3636
3737export const getEntityBySlugAsync = async ( slug : string ) : Promise < IEntity > => {
38- const entities : IEntity [ ] = await getEntities ( ) ;
39- const entity : IEntity | undefined = entities . find ( obj => obj . slug === slug ) ;
40- if ( ! entity ) { throw new Error ( `failed to githubGet entity for ${ slug } ` ) ; }
41- return entity ;
38+ const entities : IEntity [ ] = await getEntities ( ) ;
39+ const entity : IEntity | undefined = entities . find ( obj => obj . slug === slug ) ;
40+ if ( ! entity ) {
41+ throw new Error ( `failed to githubGet entity for ${ slug } ` ) ;
42+ }
43+
44+ return entity ;
4245} ;
4346
4447export const getEntityByIdAsync = async ( id : string ) : Promise < IEntity > => {
You can’t perform that action at this time.
0 commit comments