sakuraapi / cli

Command Line Interface for Scaffolding and Managing SakuraAPI Projects
BSD 3-Clause "New" or "Revised" License
4 stars 1 forks source link

Implement generators for new Models, Services and Routables #10

Closed etsuo closed 6 years ago

etsuo commented 6 years ago

This has become expecially important because of how mixins work (don't work?) with TypeScript 2.6 (see: https://github.com/Microsoft/TypeScript/issues/9944).

So, for example to get an @Model working, there's an export tap dance that needs to happen:

import {
  Db,
  IDbGetParams,
  IFromDbOptions,
  Json,
  Model,
  SakuraApi,
  SapiModelMixin
}            from '@sakuraapi/api';
import {
  Collection,
  CollectionInsertOneOptions,
  CollectionOptions,
  Cursor,
  Db as MongoDb,
  DeleteWriteOpResultObject,
  InsertOneWriteOpResult,
  ObjectID,
  ReplaceOneOptions,
  UpdateWriteOpResult
}            from 'mongodb';
import {dbs} from '../config/db';

export {
  Collection,
  CollectionInsertOneOptions,
  CollectionOptions,
  Cursor,
  MongoDb,
  DeleteWriteOpResultObject,
  InsertOneWriteOpResult,
  ObjectID,
  ReplaceOneOptions,
  UpdateWriteOpResult,
  IDbGetParams,
  IFromDbOptions,
  SakuraApi
};

@Model({
  dbConfig: dbs.user
})
export class User extends SapiModelMixin() {
}

That's a lot of setup work. It looks like TypeScript issue 9944 is scheduled to have some sort of solution in 2.8, so revisit the issue then. In the meantime, sapi cli needs to reduce the pain in setting up a model.

Might as well create generators for Services and Routables at the same time.