Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
N
nicot
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
3rdeye
nicot
Commits
af1fccaa
Commit
af1fccaa
authored
Oct 28, 2024
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move to nesties
parent
2eeb7974
Changes
16
Show whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
84 additions
and
220 deletions
+84
-220
index.ts
index.ts
+1
-0
package-lock.json
package-lock.json
+69
-8
package.json
package.json
+1
-0
src/bases/id-base.ts
src/bases/id-base.ts
+1
-1
src/bases/page-settings.ts
src/bases/page-settings.ts
+1
-5
src/crud-base.ts
src/crud-base.ts
+6
-6
src/decorators/access.ts
src/decorators/access.ts
+1
-1
src/decorators/index.ts
src/decorators/index.ts
+0
-1
src/decorators/merge.ts
src/decorators/merge.ts
+0
-37
src/decorators/pipes.ts
src/decorators/pipes.ts
+0
-6
src/decorators/property.ts
src/decorators/property.ts
+1
-1
src/decorators/restful.ts
src/decorators/restful.ts
+3
-4
src/dto/index.ts
src/dto/index.ts
+0
-1
src/dto/return-message.ts
src/dto/return-message.ts
+0
-143
src/utility/api-error.ts
src/utility/api-error.ts
+0
-5
src/utility/index.ts
src/utility/index.ts
+0
-1
No files found.
index.ts
View file @
af1fccaa
import
'
reflect-metadata
'
;
export
*
from
'
nesties
'
;
export
*
from
'
./src/crud-base
'
;
export
*
from
'
./src/bases
'
;
export
*
from
'
./src/decorators
'
;
...
...
package-lock.json
View file @
af1fccaa
...
...
@@ -10,6 +10,7 @@
"license"
:
"MIT"
,
"dependencies"
:
{
"lodash"
:
"^4.17.21"
,
"nesties"
:
"^1.0.1"
,
"typed-reflector"
:
"^1.0.11"
},
"devDependencies"
:
{
...
...
@@ -35,8 +36,8 @@
"typescript"
:
"^4.7.4"
},
"peerDependencies"
:
{
"@nestjs/common"
:
"^9.4.0"
,
"@nestjs/swagger"
:
"^7.1.8"
,
"@nestjs/common"
:
"^9.4.0
|| ^10.0.0
"
,
"@nestjs/swagger"
:
"^7.1.8
|| ^6.3.0
"
,
"class-transformer"
:
"^0.5.1"
,
"class-validator"
:
"^0.14.0"
,
"typeorm"
:
"^0.3.16"
...
...
@@ -1123,6 +1124,21 @@
"integrity"
:
"sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg=="
,
"peer"
:
true
},
"node_modules/@nestjs/config"
:
{
"version"
:
"3.3.0"
,
"resolved"
:
"https://registry.npmjs.org/@nestjs/config/-/config-3.3.0.tgz"
,
"integrity"
:
"sha512-pdGTp8m9d0ZCrjTpjkUbZx6gyf2IKf+7zlkrPNMsJzYZ4bFRRTpXrnj+556/5uiI6AfL5mMrJc2u7dB6bvM+VA=="
,
"peer"
:
true
,
"dependencies"
:
{
"dotenv"
:
"16.4.5"
,
"dotenv-expand"
:
"10.0.0"
,
"lodash"
:
"4.17.21"
},
"peerDependencies"
:
{
"@nestjs/common"
:
"^8.0.0 || ^9.0.0 || ^10.0.0"
,
"rxjs"
:
"^7.1.0"
}
},
"node_modules/@nestjs/core"
:
{
"version"
:
"9.4.0"
,
"resolved"
:
"https://registry.npmjs.org/@nestjs/core/-/core-9.4.0.tgz"
,
...
...
@@ -2656,9 +2672,21 @@
}
},
"node_modules/dotenv"
:
{
"version"
:
"16.0.3"
,
"resolved"
:
"https://registry.npmjs.org/dotenv/-/dotenv-16.0.3.tgz"
,
"integrity"
:
"sha512-7GO6HghkA5fYG9TYnNxi14/7K9f5occMlp3zXAuSxn7CKCxt9xbNWG7yF8hTCSUchlfWSe3uLmlPfigevRItzQ=="
,
"version"
:
"16.4.5"
,
"resolved"
:
"https://registry.npmjs.org/dotenv/-/dotenv-16.4.5.tgz"
,
"integrity"
:
"sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg=="
,
"peer"
:
true
,
"engines"
:
{
"node"
:
">=12"
},
"funding"
:
{
"url"
:
"https://dotenvx.com"
}
},
"node_modules/dotenv-expand"
:
{
"version"
:
"10.0.0"
,
"resolved"
:
"https://registry.npmjs.org/dotenv-expand/-/dotenv-expand-10.0.0.tgz"
,
"integrity"
:
"sha512-GopVGCpVS1UKH75VKHGuQFqS1Gusej0z4FyQkPdwjil2gNIv+LNsqBlboOzpJFZKVT95GkCyWJbBSdFEFUWI2A=="
,
"peer"
:
true
,
"engines"
:
{
"node"
:
">=12"
...
...
@@ -4821,6 +4849,16 @@
"node"
:
">= 0.6"
}
},
"node_modules/nesties"
:
{
"version"
:
"1.0.1"
,
"resolved"
:
"https://registry.npmjs.org/nesties/-/nesties-1.0.1.tgz"
,
"integrity"
:
"sha512-WDc+/sEDGMnHmMD2lZSSxMqMsml0SxyxoDkQhfo5xd78xjQUcO1o4fOUfkPV4pSsTPdhqLO97E0OwPbKXuc7Gw=="
,
"peerDependencies"
:
{
"@nestjs/common"
:
"^9.4.0 || ^10.0.0"
,
"@nestjs/config"
:
"^3.0.0"
,
"@nestjs/swagger"
:
"^7.1.8 || ^6.3.0"
}
},
"node_modules/node-fetch"
:
{
"version"
:
"2.6.7"
,
"resolved"
:
"https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz"
,
...
...
@@ -7583,6 +7621,17 @@
}
}
},
"@nestjs/config"
:
{
"version"
:
"3.3.0"
,
"resolved"
:
"https://registry.npmjs.org/@nestjs/config/-/config-3.3.0.tgz"
,
"integrity"
:
"sha512-pdGTp8m9d0ZCrjTpjkUbZx6gyf2IKf+7zlkrPNMsJzYZ4bFRRTpXrnj+556/5uiI6AfL5mMrJc2u7dB6bvM+VA=="
,
"peer"
:
true
,
"requires"
:
{
"dotenv"
:
"16.4.5"
,
"dotenv-expand"
:
"10.0.0"
,
"lodash"
:
"4.17.21"
}
},
"@nestjs/core"
:
{
"version"
:
"9.4.0"
,
"resolved"
:
"https://registry.npmjs.org/@nestjs/core/-/core-9.4.0.tgz"
,
...
...
@@ -8692,9 +8741,15 @@
}
},
"dotenv"
:
{
"version"
:
"16.0.3"
,
"resolved"
:
"https://registry.npmjs.org/dotenv/-/dotenv-16.0.3.tgz"
,
"integrity"
:
"sha512-7GO6HghkA5fYG9TYnNxi14/7K9f5occMlp3zXAuSxn7CKCxt9xbNWG7yF8hTCSUchlfWSe3uLmlPfigevRItzQ=="
,
"version"
:
"16.4.5"
,
"resolved"
:
"https://registry.npmjs.org/dotenv/-/dotenv-16.4.5.tgz"
,
"integrity"
:
"sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg=="
,
"peer"
:
true
},
"dotenv-expand"
:
{
"version"
:
"10.0.0"
,
"resolved"
:
"https://registry.npmjs.org/dotenv-expand/-/dotenv-expand-10.0.0.tgz"
,
"integrity"
:
"sha512-GopVGCpVS1UKH75VKHGuQFqS1Gusej0z4FyQkPdwjil2gNIv+LNsqBlboOzpJFZKVT95GkCyWJbBSdFEFUWI2A=="
,
"peer"
:
true
},
"ee-first"
:
{
...
...
@@ -10330,6 +10385,12 @@
"integrity"
:
"sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg=="
,
"devOptional"
:
true
},
"nesties"
:
{
"version"
:
"1.0.1"
,
"resolved"
:
"https://registry.npmjs.org/nesties/-/nesties-1.0.1.tgz"
,
"integrity"
:
"sha512-WDc+/sEDGMnHmMD2lZSSxMqMsml0SxyxoDkQhfo5xd78xjQUcO1o4fOUfkPV4pSsTPdhqLO97E0OwPbKXuc7Gw=="
,
"requires"
:
{}
},
"node-fetch"
:
{
"version"
:
"2.6.7"
,
"resolved"
:
"https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz"
,
...
...
package.json
View file @
af1fccaa
...
...
@@ -69,6 +69,7 @@
},
"dependencies"
:
{
"
lodash
"
:
"
^4.17.21
"
,
"
nesties
"
:
"
^1.0.1
"
,
"
typed-reflector
"
:
"
^1.0.11
"
}
}
src/bases/id-base.ts
View file @
af1fccaa
...
...
@@ -3,12 +3,12 @@ import { Generated, SelectQueryBuilder } from 'typeorm';
import
{
applyQueryProperty
}
from
'
../utility
'
;
import
{
IntColumn
,
MergePropertyDecorators
,
NotChangeable
,
NotWritable
,
StringColumn
,
}
from
'
../decorators
'
;
import
{
IsNotEmpty
}
from
'
class-validator
'
;
import
{
MergePropertyDecorators
}
from
'
nesties
'
;
export
interface
IdOptions
{
description
?:
string
;
...
...
src/bases/page-settings.ts
View file @
af1fccaa
...
...
@@ -3,11 +3,7 @@ import { SelectQueryBuilder } from 'typeorm';
import
{
IsInt
,
IsPositive
}
from
'
class-validator
'
;
import
{
ApiProperty
}
from
'
@nestjs/swagger
'
;
import
{
reflector
}
from
'
../utility/metadata
'
;
export
interface
PageSettingsWise
{
pageCount
:
number
;
recordsPerPage
:
number
;
}
import
{
PageSettingsWise
}
from
'
nesties
'
;
export
interface
PageSettingsFactory
{
getActualPageSettings
():
PageSettingsWise
;
...
...
src/crud-base.ts
View file @
af1fccaa
import
{
BlankReturnMessageDto
,
ImportEntryDto
,
PaginatedReturnMessageDto
,
ReturnMessageDto
,
}
from
'
./dto
'
;
import
{
ImportEntryDto
}
from
'
./dto
'
;
import
{
DeepPartial
,
DeleteResult
,
...
...
@@ -23,6 +18,11 @@ import { ConsoleLogger } from '@nestjs/common';
import
{
camelCase
}
from
'
typeorm/util/StringUtils
'
;
import
_
from
'
lodash
'
;
import
{
ClassType
}
from
'
./utility/insert-field
'
;
import
{
BlankReturnMessageDto
,
PaginatedReturnMessageDto
,
ReturnMessageDto
,
}
from
'
nesties
'
;
export
type
EntityId
<
T
extends
{
id
:
any
}
>
=
T
[
'
id
'
];
export
interface
RelationDef
{
...
...
src/decorators/access.ts
View file @
af1fccaa
import
{
Expose
}
from
'
class-transformer
'
;
import
{
IsOptional
}
from
'
class-validator
'
;
import
{
Metadata
}
from
'
../utility/metadata
'
;
import
{
MergePropertyDecorators
}
from
'
./merge
'
;
import
{
MergePropertyDecorators
}
from
'
nesties
'
;
export
const
NotWritable
=
()
=>
MergePropertyDecorators
([
...
...
src/decorators/index.ts
View file @
af1fccaa
export
*
from
'
./access
'
;
export
*
from
'
./merge
'
;
export
*
from
'
./property
'
;
export
*
from
'
./restful
'
;
export
*
from
'
./pipes
'
;
...
...
src/decorators/merge.ts
deleted
100644 → 0
View file @
2eeb7974
export
function
MergePropertyDecorators
(
decs
:
PropertyDecorator
[],
):
PropertyDecorator
{
return
(
obj
,
key
)
=>
{
for
(
const
dec
of
decs
)
{
dec
(
obj
,
key
);
}
};
}
export
function
MergeMethodDecorators
(
decs
:
MethodDecorator
[],
):
MethodDecorator
{
return
(
obj
,
key
,
descriptor
)
=>
{
for
(
const
dec
of
decs
)
{
dec
(
obj
,
key
,
descriptor
);
}
};
}
export
function
MergeClassDecorators
(
decs
:
ClassDecorator
[]):
ClassDecorator
{
return
(
obj
)
=>
{
for
(
const
dec
of
decs
)
{
dec
(
obj
);
}
};
}
export
function
MergeParameterDecorators
(
decs
:
ParameterDecorator
[],
):
ParameterDecorator
{
return
(
obj
,
key
,
index
)
=>
{
for
(
const
dec
of
decs
)
{
dec
(
obj
,
key
,
index
);
}
};
}
src/decorators/pipes.ts
View file @
af1fccaa
...
...
@@ -23,9 +23,3 @@ export const UpdatePipe = () =>
skipNullProperties
:
true
,
skipUndefinedProperties
:
true
,
});
export
const
DataPipe
=
()
=>
new
ValidationPipe
({
transform
:
true
,
transformOptions
:
{
enableImplicitConversion
:
true
},
});
src/decorators/property.ts
View file @
af1fccaa
import
{
ColumnCommonOptions
}
from
'
typeorm/decorator/options/ColumnCommonOptions
'
;
import
{
ApiProperty
,
ApiPropertyOptions
}
from
'
@nestjs/swagger
'
;
import
{
ColumnWithLengthOptions
}
from
'
typeorm/decorator/options/ColumnWithLengthOptions
'
;
import
{
MergePropertyDecorators
}
from
'
./merge
'
;
import
{
MergePropertyDecorators
}
from
'
nesties
'
;
import
{
Column
,
Index
}
from
'
typeorm
'
;
import
{
IsDate
,
...
...
src/decorators/restful.ts
View file @
af1fccaa
...
...
@@ -9,14 +9,13 @@ import {
Post
,
Query
,
}
from
'
@nestjs/common
'
;
import
{
ImportDataDto
,
ImportEntryDto
}
from
'
../dto
'
;
import
{
BlankReturnMessageDto
,
ImportDataDto
,
ImportEntryDto
,
MergeMethodDecorators
,
PaginatedReturnMessageDto
,
ReturnMessageDto
,
}
from
'
../dto
'
;
import
{
MergeMethodDecorators
}
from
'
./merge
'
;
}
from
'
nesties
'
;
import
{
ClassType
}
from
'
../utility/insert-field
'
;
import
{
ApiBadRequestResponse
,
...
...
src/dto/index.ts
View file @
af1fccaa
export
*
from
'
./return-message
'
;
export
*
from
'
./import-entry
'
;
src/dto/return-message.ts
deleted
100644 → 0
View file @
2eeb7974
import
{
ApiProperty
}
from
'
@nestjs/swagger
'
;
import
{
HttpException
}
from
'
@nestjs/common
'
;
import
{
PageSettingsWise
}
from
'
../bases/page-settings
'
;
import
{
AnyClass
,
ClassOrArray
,
getClassFromClassOrArray
,
InsertField
,
ParseType
,
}
from
'
../utility/insert-field
'
;
export
interface
BlankReturnMessage
{
statusCode
:
number
;
message
:
string
;
success
:
boolean
;
}
export
interface
ReturnMessage
<
T
>
extends
BlankReturnMessage
{
data
?:
T
;
}
export
class
BlankReturnMessageDto
implements
BlankReturnMessage
{
@
ApiProperty
({
description
:
'
Return code
'
,
type
:
Number
})
statusCode
:
number
;
@
ApiProperty
({
description
:
'
Return message
'
,
type
:
String
})
message
:
string
;
@
ApiProperty
({
description
:
'
Whether success.
'
,
type
:
Boolean
})
success
:
boolean
;
constructor
(
statusCode
:
number
,
message
?:
string
)
{
this
.
statusCode
=
statusCode
;
this
.
message
=
message
||
'
success
'
;
this
.
success
=
statusCode
<
400
;
}
toException
()
{
return
new
HttpException
(
this
,
this
.
statusCode
);
}
}
export
class
BlankPaginatedReturnMessageDto
extends
BlankReturnMessageDto
implements
PageSettingsWise
{
@
ApiProperty
({
description
:
'
Total record count.
'
,
type
:
Number
})
total
:
number
;
@
ApiProperty
({
description
:
'
Total page count.
'
,
type
:
Number
})
totalPages
:
number
;
@
ApiProperty
({
description
:
'
Current page.
'
,
type
:
Number
})
pageCount
:
number
;
@
ApiProperty
({
description
:
'
Records per page.
'
,
type
:
Number
})
recordsPerPage
:
number
;
constructor
(
statusCode
:
number
,
message
:
string
,
total
:
number
,
pageSettings
:
PageSettingsWise
,
)
{
super
(
statusCode
,
message
);
this
.
total
=
total
;
this
.
pageCount
=
pageSettings
.
pageCount
;
this
.
recordsPerPage
=
pageSettings
.
recordsPerPage
;
this
.
totalPages
=
Math
.
ceil
(
total
/
pageSettings
.
recordsPerPage
);
}
}
export
class
GenericReturnMessageDto
<
T
>
extends
BlankReturnMessageDto
implements
ReturnMessage
<
T
>
{
data
?:
T
;
constructor
(
statusCode
:
number
,
message
?:
string
,
data
?:
T
)
{
super
(
statusCode
,
message
);
this
.
data
=
data
;
}
}
export
function
ReturnMessageDto
<
T
extends
ClassOrArray
>
(
type
:
T
,
):
new
(
statusCode
:
number
,
message
:
string
,
data
:
ParseType
<
T
>
,
)
=>
GenericReturnMessageDto
<
ParseType
<
T
>>
{
return
InsertField
(
GenericReturnMessageDto
,
{
data
:
{
type
,
options
:
{
required
:
false
,
description
:
'
Return data.
'
,
},
},
},
`
${
getClassFromClassOrArray
(
type
).
name
}
ReturnMessageDto`
,
);
}
export
class
GenericPaginatedReturnMessageDto
<
T
>
extends
BlankPaginatedReturnMessageDto
implements
PageSettingsWise
,
ReturnMessage
<
T
[]
>
{
data
:
T
[];
constructor
(
statusCode
:
number
,
message
:
string
,
data
:
T
[],
total
:
number
,
pageSettings
:
PageSettingsWise
,
)
{
super
(
statusCode
,
message
,
total
,
pageSettings
);
this
.
data
=
data
;
}
}
export
function
PaginatedReturnMessageDto
<
T
extends
AnyClass
>
(
type
:
T
,
):
new
(
statusCode
:
number
,
message
:
string
,
data
:
InstanceType
<
T
>
[],
total
:
number
,
pageSettings
:
PageSettingsWise
,
)
=>
GenericPaginatedReturnMessageDto
<
InstanceType
<
T
>>
{
return
InsertField
(
GenericPaginatedReturnMessageDto
,
{
data
:
{
type
:
[
type
],
options
:
{
required
:
false
,
description
:
'
Return data.
'
,
},
},
},
`
${
getClassFromClassOrArray
(
type
).
name
}
PaginatedReturnMessageDto`
,
);
}
export
class
StringReturnMessageDto
extends
GenericReturnMessageDto
<
string
>
{
@
ApiProperty
({
description
:
'
Return data.
'
,
type
:
String
,
required
:
false
})
data
:
string
;
}
src/utility/api-error.ts
deleted
100644 → 0
View file @
2eeb7974
import
{
BlankReturnMessageDto
}
from
'
../dto
'
;
import
{
ApiResponse
}
from
'
@nestjs/swagger
'
;
export
const
ApiError
=
(
status
:
number
,
description
:
string
)
=>
ApiResponse
({
status
,
type
:
BlankReturnMessageDto
,
description
});
src/utility/index.ts
View file @
af1fccaa
export
*
from
'
./query
'
;
export
*
from
'
./api-error
'
;
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