TokenDao: Export as default alongside TokenData
Our coding standards are to create a separate file for classes and interfaces, but this is a bit different: this "interface" is more like a struct, and it's used to define the return type of a method of this class. Since it's inherently coupled, I'm keeping it in the same file. The idea is that the caller will provide its own abstraction rather than continuing to export this one. Note that Typescript does support re-exporting symbols if need be. * src/server/daemon/controller.js: Adjust import of TokenDao (TS compiles default modules as `default'). * src/server/service/TokenedService.js: Adjust import of TokenDao. * src/server/token/TokenDao.ts: Export TokenDao as `default'. Export TokenData. * test/server/token/TokenDaoTest.ts: Adjust import of TokenDao. Import TokenData.master
parent
c90757a6d3
commit
9dd1ae3428
|
@ -90,7 +90,9 @@ const {
|
|||
},
|
||||
|
||||
token: {
|
||||
TokenDao,
|
||||
TokenDao: {
|
||||
default: TokenDao,
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
var Trait = require( 'easejs' ).Trait,
|
||||
Class = require( 'easejs' ).Class,
|
||||
Service = require( './Service' ),
|
||||
TokenDao = require( '../token/TokenDao' );
|
||||
TokenDao = require( '../token/TokenDao' ).default;
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -28,10 +28,11 @@ import {
|
|||
TokenType,
|
||||
} from "./TokenQueryResult";
|
||||
|
||||
|
||||
/**
|
||||
* Token information
|
||||
*/
|
||||
interface TokenData
|
||||
export interface TokenData
|
||||
{
|
||||
id: string,
|
||||
status: TokenStatus,
|
||||
|
@ -43,7 +44,7 @@ interface TokenData
|
|||
*
|
||||
* Note that this is tightly coupled with MongoDB.
|
||||
*/
|
||||
export = class TokenDao
|
||||
export default class TokenDao
|
||||
{
|
||||
/**
|
||||
* Mongo database collection
|
||||
|
|
|
@ -19,15 +19,17 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { expect, use as chai_use } from 'chai';
|
||||
|
||||
import {
|
||||
TokenQueryResult,
|
||||
TokenStatus,
|
||||
} from "../../../src/server/token/TokenQueryResult";
|
||||
|
||||
import Sut = require( "../../../src/server/token/TokenDao" );
|
||||
import {
|
||||
default as Sut,
|
||||
TokenData,
|
||||
} from "../../../src/server/token/TokenDao";
|
||||
|
||||
import { expect, use as chai_use } from 'chai';
|
||||
chai_use( require( 'chai-as-promised' ) );
|
||||
|
||||
|
||||
|
@ -118,8 +120,7 @@ describe( 'server.token.TokenDao', () =>
|
|||
data: "",
|
||||
};
|
||||
|
||||
// TODO: export and use TokenData
|
||||
( <[string, string, TokenQueryResult, any][]>[
|
||||
( <[string, string, TokenQueryResult, TokenData][]>[
|
||||
[
|
||||
'retrieves token by id',
|
||||
'tok123',
|
||||
|
|
Loading…
Reference in New Issue