Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
C
console
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
console
Commits
e5bdf3df
Commit
e5bdf3df
authored
Jan 04, 2017
by
wudizhanche1000
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
调整后端
parent
8ff09af6
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
225 additions
and
18 deletions
+225
-18
app/app-detail.component.ts
app/app-detail.component.ts
+1
-1
app/app.service.ts
app/app.service.ts
+1
-1
app/apps.component.ts
app/apps.component.ts
+1
-1
db/decorators.ts
db/decorators.ts
+1
-4
koa/errors.ts
koa/errors.ts
+5
-0
models/app.ts
models/app.ts
+14
-2
models/errors.ts
models/errors.ts
+14
-0
node_modules/@types/mongorito/index.d.ts
node_modules/@types/mongorito/index.d.ts
+126
-5
npm-debug.log
npm-debug.log
+49
-0
routes/apps.ts
routes/apps.ts
+13
-4
No files found.
app/app-detail.component.ts
View file @
e5bdf3df
import
{
Component
,
OnInit
}
from
'
@angular/core
'
;
import
App
from
'
../models/app
'
;
import
{
AppService
}
from
'
./app.service
'
;
import
{
ActivatedRoute
,
Params
}
from
'
@angular/router
'
;
import
'
rxjs/Rx
'
;
import
{
MdIconRegistry
}
from
'
@angular/material
'
;
import
{
DomSanitizer
}
from
'
@angular/platform-browser
'
;
import
{
App
}
from
'
../models/app
'
;
@
Component
({
selector
:
'
app-detail
'
,
...
...
app/app.service.ts
View file @
e5bdf3df
import
{
Injectable
}
from
'
@angular/core
'
;
import
App
from
'
../models/app
'
;
import
{
Http
}
from
'
@angular/http
'
;
import
'
rxjs/add/operator/toPromise
'
;
import
{
App
}
from
'
../models/app
'
;
/**
* Created by weijian on 2016/12/30.
*/
...
...
app/apps.component.ts
View file @
e5bdf3df
import
{
Component
,
OnInit
}
from
'
@angular/core
'
;
import
App
from
'
../models/app
'
;
import
{
AppService
}
from
'
./app.service
'
;
import
{
App
}
from
'
../models/app
'
;
@
Component
({
selector
:
'
apps
'
,
...
...
db/decorators.ts
View file @
e5bdf3df
import
*
as
Mongorito
from
'
mongorito
'
;
import
Model
=
Mongorito
.
Model
;
/**
* Created by weijian on 2016/12/30.
*/
export
function
field
(
target
:
Model
,
propertyKey
:
string
):
any
{
export
function
field
(
target
:
any
,
propertyKey
:
string
):
any
{
return
{
get
():
any
{
return
this
.
get
(
propertyKey
);
...
...
koa/errors.ts
View file @
e5bdf3df
...
...
@@ -14,5 +14,10 @@ export class NotFound extends KoaError {
super
(
msg
,
404
);
}
}
export
class
BadRequest
extends
KoaError
{
constructor
(
msg
=
STATUS_CODES
[
400
])
{
super
(
msg
,
400
);
}
}
export
const
InternalError
=
new
KoaError
(
STATUS_CODES
[
500
],
500
);
models/app.ts
View file @
e5bdf3df
...
...
@@ -2,13 +2,14 @@ import 'reflect-metadata';
import
*
as
Mongorito
from
'
mongorito
'
;
import
Model
=
Mongorito
.
Model
;
import
{
field
}
from
'
../db/decorators
'
;
import
{
ModelExistsError
}
from
'
./errors
'
;
/**
* Created by weijian on 2016/12/28.
*/
interface
I18n
<
T
>
{
[
locale
:
string
]:
T
;
}
class
App
extends
Model
{
export
class
App
extends
Model
{
@
field
id
:
string
;
@
field
...
...
@@ -23,6 +24,17 @@ class App extends Model {
conference
?:
string
;
@
field
data
:
any
;
async
checkExists
()
{
let
app
=
await
App
.
findOne
({
id
:
this
.
id
});
if
(
app
)
{
throw
new
ModelExistsError
(
this
.
id
);
}
}
configure
()
{
this
.
before
(
'
create
'
,
this
.
checkExists
);
}
}
export
default
App
;
models/errors.ts
0 → 100644
View file @
e5bdf3df
/**
* Created by weijian on 2017/1/4.
*/
class
ModelError
extends
Error
{
constructor
(
msg
:
string
)
{
super
(
msg
);
}
}
export
class
ModelExistsError
extends
Error
{
constructor
(
id
:
string
)
{
super
(
`App
${
id
}
already exists`
);
}
}
node_modules/@types/mongorito/index.d.ts
View file @
e5bdf3df
...
...
@@ -7,30 +7,151 @@ import * as mongodb from "mongodb";
declare
module
Mongorito
{
function
connect
(
url
:
string
):
Promise
<
mongodb
.
Db
>
function
setDriver
(
driver
:
any
);
function
getDriver
():
any
;
interface
Options
{
[
skip
:
string
]:
string
|
string
[];
}
class
Model
{
constructor
(
o
:
any
,
options
?:
Object
);
save
(
options
?:
any
):
Promise
<
any
>
;
get
(
key
:
string
):
any
;
create
(
options
?:
any
):
Promise
<
any
>
;
set
(
key
:
string
,
value
:
Object
)
;
u
pdate
(
options
?:
any
):
Promise
<
any
>
;
u
nset
(
key
:
string
)
;
remove
(
options
?:
any
):
Promise
<
any
>
;
toJSON
()
;
static
remove
(
query
:
Object
):
Promise
<
any
>
;
before
(
action
:
string
,
method
:
Function
);
before
(
action
:
string
,
method
:
Function
[]);
before
(
action
:
string
,
method
:
string
);
before
(
action
:
string
,
method
:
string
[]);
after
(
action
:
string
,
method
:
Function
);
after
(
action
:
string
,
method
:
Function
[]);
after
(
action
:
string
,
method
:
string
);
after
(
action
:
string
,
method
:
string
[]);
around
(
action
:
string
,
method
:
Function
);
around
(
action
:
string
,
method
:
Function
[]);
around
(
action
:
string
,
method
:
string
);
around
(
action
:
string
,
method
:
string
[]);
/**
* Configure model (usually, set hooks here)
* Supposed to be overriden
*
* @api public
*/
configure
();
/**
* Save a model
*
* @param {Object} options - options for save operation
* @api public
*/
save
(
options
?:
Options
):
Promise
<
any
>
;
/**
* Create a model
*
* @api private
*/
create
(
options
?:
Options
):
Promise
<
any
>
;
update
(
options
?:
Options
):
Promise
<
any
>
;
remove
(
options
?:
Options
):
Promise
<
any
>
;
/**
* Atomically increment a model property
*
* @param {Object} props - set of properties and values
* @param {Object} options - options for update operation
* @api public
*/
inc
(
props
:
Object
,
options
:
Options
);
/**
* Find documents
*
* @param {Object} query - find conditions, same as this.where()
* @api public
*/
static
find
(
query
:
Object
):
Promise
<
any
[]
>
;
/**
* Count documents
*
* @param {Object} query - find conditions, same as this.where()
* @api public
*/
static
count
(
query
:
Object
):
Promise
<
any
>
;
/**
* Get distinct
*
* @param {String} field for distinct
* @param {Object} query - query to filter the results
* @see http://mongodb.github.io/node-mongodb-native/2.0/api/Collection.html#distinct
* @api public
*/
static
distinct
(
filed
:
string
,
query
?:
Object
):
Promise
<
any
>
;
/**
* Aggregation query
*
* @param {String} pipeline aggregation pipeline
* @param {Object} options - Options to be passed to aggregation pipeline
* @see http://mongodb.github.io/node-mongodb-native/2.0/api/Collection.html#distinct
* @api public
*/
static
aggregate
(
pipeline
:
Object
[]):
Promise
<
any
>
;
/**
* Find all documents in a collection
*
* @api public
*/
static
all
():
Promise
<
any
[]
>
/**
* Find one document
*
* @param {Object} query - find conditions, same as this.where()
* @api public
*/
static
findOne
(
query
:
Object
):
Promise
<
any
>
;
/**
* Find a document by ID
*
* @param {ObjectID} id - document id
* @api public
*/
static
findById
(
id
:
string
):
Promise
<
any
>
;
/**
* Remove documents
*
* @param {Object} query - remove conditions, same as this.where()
* @api public
*/
static
remove
(
query
:
Object
):
Promise
<
any
>
;
/**
* Drop collection
*
* @api public
*/
static
drop
():
Promise
<
any
>
;
}
...
...
npm-debug.log
0 → 100644
View file @
e5bdf3df
0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'run',
1 verbose cli 'start' ]
2 info using npm@3.10.10
3 info using node@v7.3.0
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle mycard-console@1.0.0~prestart: mycard-console@1.0.0
6 silly lifecycle mycard-console@1.0.0~prestart: no script for prestart, continuing
7 info lifecycle mycard-console@1.0.0~start: mycard-console@1.0.0
8 verbose lifecycle mycard-console@1.0.0~start: unsafe-perm in lifecycle true
9 verbose lifecycle mycard-console@1.0.0~start: PATH: C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin;D:\Github\mycard-console\node_modules\.bin;C:\Program Files\Docker\Docker\Resources\bin;C:\ProgramData\Oracle\Java\javapath;C:\Python27\;C:\Python27\Scripts;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Users\weijian\.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files\Git\cmd;C:\Go\bin;C:\Program Files\TortoiseSVN\bin;C:\Program Files (x86)\GtkSharp\2.12\bin;C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit\;C:\Program Files (x86)\Microsoft Emulator Manager\1.0\;C:\Program Files\nodejs\;C:\Program Files\OpenVPN\bin;C:\Users\weijian\AppData\Local\Microsoft\WindowsApps;D:\msys;C:\Program Files (x86)\Microsoft VS Code\bin;C:\Users\weijian\AppData\Local\atom\bin;C:\Program Files\CMake\bin;C:\Users\weijian\AppData\Roaming\npm
10 verbose lifecycle mycard-console@1.0.0~start: CWD: D:\Github\mycard-console
11 silly lifecycle mycard-console@1.0.0~start: Args: [ '/d /s /c',
11 silly lifecycle 'tsc && concurrently "node server.js" "lite-server"' ]
12 silly lifecycle mycard-console@1.0.0~start: Returned: code: 2 signal: null
13 info lifecycle mycard-console@1.0.0~start: Failed to exec start script
14 verbose stack Error: mycard-console@1.0.0 start: `tsc && concurrently "node server.js" "lite-server"`
14 verbose stack Exit status 2
14 verbose stack at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\lib\utils\lifecycle.js:255:16)
14 verbose stack at emitTwo (events.js:106:13)
14 verbose stack at EventEmitter.emit (events.js:191:7)
14 verbose stack at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\lib\utils\spawn.js:40:14)
14 verbose stack at emitTwo (events.js:106:13)
14 verbose stack at ChildProcess.emit (events.js:191:7)
14 verbose stack at maybeClose (internal/child_process.js:885:16)
14 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
15 verbose pkgid mycard-console@1.0.0
16 verbose cwd D:\Github\mycard-console
17 error Windows_NT 10.0.14393
18 error argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "start"
19 error node v7.3.0
20 error npm v3.10.10
21 error code ELIFECYCLE
22 error mycard-console@1.0.0 start: `tsc && concurrently "node server.js" "lite-server"`
22 error Exit status 2
23 error Failed at the mycard-console@1.0.0 start script 'tsc && concurrently "node server.js" "lite-server"'.
23 error Make sure you have the latest version of node.js and npm installed.
23 error If you do, this is most likely a problem with the mycard-console package,
23 error not with npm itself.
23 error Tell the author that this fails on your system:
23 error tsc && concurrently "node server.js" "lite-server"
23 error You can get information on how to open an issue for this project with:
23 error npm bugs mycard-console
23 error Or if that isn't available, you can get their info via:
23 error npm owner ls mycard-console
23 error There is likely additional logging output above.
24 verbose exit [ 1, true ]
routes/apps.ts
View file @
e5bdf3df
...
...
@@ -2,13 +2,14 @@
* Created by weijian on 2016/12/28.
*/
import
Router
=
require
(
'
koa-router
'
);
import
App
from
'
../models/app
'
;
import
{
NotFound
}
from
'
../koa/errors
'
;
import
{
NotFound
,
BadRequest
,
InternalError
}
from
'
../koa/errors
'
;
import
{
Model
}
from
'
../db/mongo
'
;
import
{
App
}
from
'
../models/app
'
;
import
{
ModelExistsError
}
from
'
../models/errors
'
;
const
router
=
new
Router
();
router
.
get
(
'
/apps
'
,
async
(
ctx
,
next
)
=>
{
ctx
.
body
=
await
App
.
find
({}
);
ctx
.
body
=
await
App
.
all
(
);
});
router
.
get
(
'
/apps/:id
'
,
async
(
ctx
,
next
)
=>
{
...
...
@@ -22,7 +23,15 @@ router.get('/apps/:id', async(ctx, next) => {
router
.
post
(
'
/apps/:id
'
,
async
(
ctx
,
next
)
=>
{
let
app
=
new
App
(
ctx
.
request
.
body
);
ctx
.
body
=
await
app
.
save
();
try
{
ctx
.
body
=
await
app
.
save
();
}
catch
(
e
)
{
if
(
e
instanceof
ModelExistsError
)
{
throw
new
BadRequest
();
}
else
{
throw
InternalError
;
}
}
});
router
.
patch
(
'
/apps/:id
'
,
async
(
ctx
,
next
)
=>
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment