This repository was archived by the owner on Feb 4, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +21
-2
lines changed Expand file tree Collapse file tree 3 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -262,7 +262,11 @@ function nestOne(
262
262
} ;
263
263
}
264
264
265
- export function nest ( nesting : Nesting , notNestedDesignDocumentParts : DesignDocumentPart [ ] , raster : boolean ) {
265
+ export function nest (
266
+ nesting : Nesting ,
267
+ notNestedDesignDocumentParts : DesignDocumentPart [ ] ,
268
+ raster : boolean ,
269
+ ) : { allNestedParts : Part [ ] ; newlyNestedDesignDocumentParts : DesignDocumentPart [ ] } {
266
270
let newlyNestedDesignDocumentParts : DesignDocumentPart [ ] = [ ] ;
267
271
268
272
const [ sheetWidth , sheetHeight ] = [ nesting . sheetWidth , nesting . sheetHeight ] ;
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import { createServer } from "http";
4
4
import moment from "moment" ;
5
5
import { noFitPolygon , rasterDifference } from "./nfp" ;
6
6
import { time , toFormattedDateTimeString } from "./utils" ;
7
+ import { nest } from "./nesting" ;
7
8
8
9
export function listen ( port : number ) {
9
10
const app = express ( ) ;
@@ -53,6 +54,20 @@ export function listen(port: number) {
53
54
return res . json ( result . map ( ( dot : any ) => ( { X : dot [ 0 ] , Y : dot [ 1 ] } ) ) ) ;
54
55
} ) ;
55
56
57
+ app . post ( `/rest/nest` , async ( req , res ) => {
58
+ const { nestingJson, notNestedDesignDocumentPartsJson, raster } = req . body ;
59
+
60
+ const nesting = JSON . parse ( nestingJson as any ) ;
61
+ const notNestedDesignDocumentParts = JSON . parse ( notNestedDesignDocumentPartsJson as any ) ;
62
+
63
+ const result = time (
64
+ ( result ) => `nest` ,
65
+ ( ) => nest ( nesting , notNestedDesignDocumentParts , raster ) ,
66
+ ) ;
67
+
68
+ return res . json ( result ) ;
69
+ } ) ;
70
+
56
71
const server = createServer ( app ) ;
57
72
58
73
server . listen ( port , ( ) => {
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ export function toFormattedDateTimeString(moment: Moment): string {
4
4
return moment . format ( "YYYY-MM-DD HH:mm:ss" ) ;
5
5
}
6
6
7
- export function time ( name : ( result : any ) => string , func : ( ) => any ) {
7
+ export function time < T > ( name : ( result : T ) => string , func : ( ) => T ) : T {
8
8
const start = new Date ( ) . getTime ( ) ;
9
9
10
10
const result = func ( ) ;
You can’t perform that action at this time.
0 commit comments