1
0
Fork 0
Commit Graph

15 Commits (master)

Author SHA1 Message Date
Mike Gerwitz 4383d15c5a AvroFactory: Extract avro-js type definitions into src/types
The declarations that were intended for the library were moved, but
additional things that were outside of the library were kept in place.
2019-12-12 10:27:09 -05:00
Austin Schaffer d9ee999adb [DEV-5312] Refactor class dependencies
Move create config functions out of the main delta-processor.ts file. Change some any types to more specific types. Define document structure better. Move prometheus logic out of processor class. Do not call logger directly, listen for events and log them. Change logger to more PSR-3 compliant style. Extract amqp connection into its own class. Create avro and mongo objects in factory.
2019-12-12 10:14:54 -05:00
Austin Schaffer 1b96cd9147 [DEV-5312] Refactor references from 'self' to 'this', pass console into event logger, and add factory for prometheus 2019-12-12 10:10:45 -05:00
Austin Schaffer faa7e15760 [DEV-5312] Add signal handling and prometheus monitoring 2019-11-22 16:37:57 -05:00
Austin Schaffer 9b5cd4e89f [DEV-5312] Call data-processor and instantiate classes 2019-11-20 09:48:28 -05:00
Austin Schaffer 91a7cf94b2 [DEV-5312] Add dao for deltas 2019-11-12 16:21:01 -05:00
Austin Schaffer 015a3f5d47 [DEV-5312] Convert MongoServerDao to TS 2019-11-11 15:14:49 -05:00
Mike Gerwitz 2771cf2a71 src/types/misc: Add UnixTimestampMillis, Seconds, and Milliseconds
These should be moved into their own module at some point and provide
functions to convert between and to yield these types.
2019-10-24 10:30:14 -04:00
Mike Gerwitz d8c065817f NodeCallback<T, R>: New type to simplify callback declarations
Just trying to reduce some boilerplate.  I kept this as a separate commit to
illustrate clearly how this type of things is done since we'll have people
learning TypeScript.

* src/types/misc.ts (NodeCallback<T,R>): New type.
* src/server/dapi/TokenedDataApi.ts: Use it.
* test/server/dapi/TokenedDataApiTest.ts: Use it.
2019-10-18 09:55:11 -04:00
Mike Gerwitz ddf5892c83 src/types/mongo.d.ts: Add findAndModify
* src/types/mongo.d.ts (MongoCollection)[#findAndModify]: New method.
2019-10-18 09:55:10 -04:00
Mike Gerwitz fe10578949 {Context,Chained}Error: New modules
This will allow us to provide additional useful information for structure
logging.
2019-10-18 09:55:09 -04:00
Mike Gerwitz 54b3f0db72 TokenDao: Nominal typing
This beings an experiment with nominal typing using what the TS community
calls "branding".  The lack of nominal types was one of my biggest
disappointments with TS, so this should really help to mitigate bugs
resulting from misappropriation of data.

* src/server/token/Token.ts: New file.
* src/server/token/TokenDao.ts: Use Token{Id,Namespace}.
* src/server/token/TokenQueryResult.ts: Likewise.
* src/types/misc.d.ts: Introduce NominalType and UnixTimestamp.
* test/server/token/TokenDaoTest.ts: Use nominal types.
2019-10-17 11:47:14 -04:00
Mike Gerwitz 18e86ebfe7 TokenDao: Add test and further refine types
This tests the existing state of TokenDao before additional modifications
are made.  This commit also further refines the types introduced in a
previous commit.

This is also the first test written in Typescript.

* package.json.in (devDependencies): Add node, chai, and mocha types.
* src/server/token/TokenDao.ts (updateToken): `data` accepts null (as it
    should).  Do not conditionall add data to object (it doesn't matter for
    later retrieval).  Note nondeterminism with date.  More concise syntax
    for object fields.
* src/server/token/TokenQueryResult.ts: Make all fields readonly.
  (TokenStatus): Date is no longer optional (see above mention).
* src/types/mongodb.d.ts: Remove generics (erroneously added).
  (Collection)[update]: Remove 3-argument declaration (see comment).
* test/server/token/TokenDaoTest.ts: New test case.
2019-10-17 11:47:14 -04:00
Mike Gerwitz b83f13f480 TokenDao: Add type information for Mongo interactions
This adds type information for both MongoCollection and some details about
the structure of the data itself as it is stored in the database.

* src/server/token/TokenDao.ts: Import types from TokenQueryResult.
  (TokenType): Move to TokenQueryResult module.
  (TokenData)[status]: string=>TokenStatus.
  (TokenDao)[_collection]: Remove optional type specifier.
    [_collection]: Make readonly.
    [updateToken]: Use TokenStatus type for token_entry.
    [getToken]: Add return type.  Add type for query result.  Remove useless
      length check (no such field exists).  Add types for variables.
    [_getLatestToken]: Use interface instead of inline type definition.
    [_getRequestedToken]: Use type definition for `data' instead of
      `any'.  Add type of variable.
* src/server/token/TokenQueryResult.ts: Define structure of data in Mongo.
* src/types/mongodb.d.ts: Add type information for methods used by TokenDao.
2019-10-17 11:47:14 -04:00
Mike Gerwitz 5a1b84c271 TokenDao: Typescript conversion
This is the first test of integrating typescript.  I'm using the `export ='
syntax to keep imports the same using `require', but note that the `new'
keyword is now required for instantiation (whereas it was not with easejs).
2019-10-17 11:47:14 -04:00