https://github.com/samuelmarks/waterline_scaffold
Testing a waterline+TypeScript scaffold
https://github.com/samuelmarks/waterline_scaffold
Last synced: 3 months ago
JSON representation
Testing a waterline+TypeScript scaffold
- Host: GitHub
- URL: https://github.com/samuelmarks/waterline_scaffold
- Owner: SamuelMarks
- Created: 2015-09-23T12:41:59.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2015-11-03T04:11:58.000Z (over 10 years ago)
- Last Synced: 2026-01-03T16:24:42.410Z (6 months ago)
- Language: TypeScript
- Size: 188 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
waterline_scaffold
==================
Simple baseline scaffold to get you started using Waterline with TypeScript.
## Install prerequisites
0. node & npm (tested with node v4 and npm v3.3.4 on Ubuntu 15.04 x64)
1. Run: `npm install -g tsd typescript`
2. `cd` to directory you've cloned this repo into
3. Run: `npm install`
4. Run: `tsd install`
## Compile+run app
tsc --sourcemap --module commonjs db.ts && npm start
## Generate TypeScript definitions from Model
Example with "models/TUser.js", contains two variables `FFOOOOOOOOOOOOOOOOOOOO` and `BARRRRRR` containing:
```typescript
{
identity: 'user_tbl',
connection: 'postgres',
attributes: {
email: {
type: 'string',
required: true
},
password: {
type: 'string',
required: false
},
name: {
type: 'string'
}
}
};
```
Generating the interfaces; extending with `waterline.Record, waterline.Model`:
tsc --sourcemap --module commonjs codegen/model_to_def.ts
node codegen/model_to_def.js models/TUser.js 'extends waterline.Record, waterline.Model'
Will create file "models/TUser.d.ts" containing:
```typescript
export interface FFOOOOOOOOOOOOOOOOOOOO extends waterline.Record, waterline.Model {
email: string;
password?: string;
name?: string;
}
export interface BARRRRRR extends waterline.Record, waterline.Model {
email: string;
password?: string;
name?: string;
}
```