mirror of
https://github.com/janishutz/fundamentals-of-webengineering.git
synced 2025-11-25 05:44:24 +00:00
[Task 3] Fix sse crash
This commit is contained in:
@@ -19,10 +19,13 @@ const storage = multer.diskStorage( {
|
||||
) => {
|
||||
// Suggested in Multer's readme
|
||||
const uniqueSuffix = Date.now() + '-' + Math.round( Math.random() * 1E3 );
|
||||
const fname = file.fieldname + '-' + uniqueSuffix;
|
||||
// TODO: We could consider allowing the filename to be overwritten using a query param on the
|
||||
// request (i.e. url would be /upload?fname=<filename>)
|
||||
|
||||
fileEvent.emit( 'uploaded', file.fieldname + '-' + uniqueSuffix );
|
||||
fileEvent.emit( 'uploaded', fname );
|
||||
|
||||
cb( null, file.fieldname + '-' + uniqueSuffix );
|
||||
cb( null, fname );
|
||||
}
|
||||
} );
|
||||
// CSV file upload endpoint
|
||||
@@ -37,12 +40,11 @@ const fileEvent = new FileEvent();
|
||||
app.post(
|
||||
'/upload',
|
||||
upload.single( 'dataFile' ),
|
||||
(
|
||||
req, res, next
|
||||
) => {
|
||||
console.log(
|
||||
req, res, next
|
||||
);
|
||||
( _req, res ) => {
|
||||
// NOTE: We do only need the next function in the handler when we want a middleware,
|
||||
// otherwise we can simply omit it
|
||||
console.log( 'Uploaded file' );
|
||||
res.send( 'Ok' );
|
||||
}
|
||||
);
|
||||
|
||||
@@ -140,10 +142,14 @@ const sendSSEData = ( event: string, data: string ) => {
|
||||
const subs = Object.values( subscribers );
|
||||
|
||||
for ( let i = 0; i < subs.length; i++ ) {
|
||||
try {
|
||||
subs[i]!.response.write( `data: ${ JSON.stringify( {
|
||||
'event': event,
|
||||
'data': data
|
||||
} ) }\n\n` );
|
||||
} catch ( e ) {
|
||||
console.debug( e );
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
56
task_3_react/src/server/uploads/dataFile-1763362295232-475
Normal file
56
task_3_react/src/server/uploads/dataFile-1763362295232-475
Normal file
@@ -0,0 +1,56 @@
|
||||
title,artist,dancingStyle
|
||||
1 Emperor's Dream,Ballroom Dance Orchestra & Marc Reift,Slow Walz
|
||||
2 Kaiserwalzer,Ballroom Dance Orchestra & Marc Reift,Wiener Walzer
|
||||
3 Macarena (Wish),Los del Mar,Flashmob
|
||||
4 Wannabe (Wish),Spice Girls,Discofox
|
||||
5 Dancing Queen (Wish),ABBA,Discofox
|
||||
6 Splish Splash,Bobby Darin,Jive/ Rocknroll
|
||||
"7 See You Later, Alligator",Bill Haley,Jive/ Rocknroll
|
||||
8 Rico Vacilon,Pedro Garcia & His Del Prado Orchestra,Cha Cha Cha
|
||||
9 El Diablo Anda Suelto,Rey Ruiz,Cha ch cha
|
||||
10 Hips Don't Lie (Wish,Shakira,Salsa/ Discofox
|
||||
11 Como Volver a Ser Feliz,Luis Enrique,Salsa
|
||||
12 Moon River,,Slow Walz
|
||||
13 Morning has broken,Cat Stevens,Wiener Walzer
|
||||
14 Jeepers creepers,Benny Goodmann,Discofox/Foxtrott
|
||||
15 ..Baby One More Time (Wish),Britney Spears,Discofox
|
||||
16 Can't Stop the Feeling! (Wish),Justin Timberlake,Discofox
|
||||
17 Tea for Two Cha Cha,Tommy Dorsey and His Orchestra,Cha ch cha
|
||||
18 Muevelo,Rey Ruiz,Cha ch cha
|
||||
19 I feel good,Ray Charles,Jive/Rocknroll
|
||||
21 Jailhouse Rock,Elvis Presley,Jive/Rocknroll
|
||||
22 Are you lonesome,Elvis Presley,Slow Walz
|
||||
23 Louenesee,Span,Walzer
|
||||
24 Something Stupid,Michael Bubl<62>,Rumba/cha cha cha
|
||||
25 Stayin' Alive (wish),Bee Gees,Discofox
|
||||
26 Uptown Funk (Wish),Bruno Mars,Discofox
|
||||
27 suelta la cintura,Ruben leon,Cha ch cha
|
||||
28 Come Dance With Me,Michael Bubl<62>,cha cha cha
|
||||
29 Kiss me,Sixpence None the Richer,Discofox/Foxtrott
|
||||
30 ily (i love you baby) [feat. Emilee],Surf Mesa,Discofox
|
||||
31 Crazy Little Thing Called Love,Queen,Jive/ Rocknroll
|
||||
32 Great Balls of Fire,Jerry Lee Lewis,Jive/ Rocknroll
|
||||
33 La Bamba,Ritchie Valens,Jive/ Rocknroll
|
||||
34 Macho,Charles Fox,Salsa
|
||||
35 The Last Waltz,Engelbert Humperdinck,Walzer
|
||||
36 An der sch<63>nen blauen Donau,New 101 Strings Orchestra,Wiener Walzer
|
||||
37 Dance The Night,Dua Lipa,Discofox
|
||||
38 Iko Iko,Justin Wellington,Discofox
|
||||
39 Beat It (Wish),Michael Jackson,Jive
|
||||
40 Super Freaky Girl (Wish),Nicki Minaj,Jive/ Rocknroll
|
||||
41 California Girls (Wish),Katy Perry,Discofox
|
||||
3 Macarena (Wish),Los del Mar,Flashmob
|
||||
43 Ay Mujer,Rey Ruiz,Cha ch cha
|
||||
44 Lets get loud,Jennifer Lopez,Cha ch cha
|
||||
45 Friday,Riton & Nightcrawlers,Party
|
||||
46 Take On Me,a-ha,Party
|
||||
47 Gimme! Gimme! Gimme! (Wish),ABBA,Party
|
||||
48 I Gotta Feeling (Wish),Black Eyed Peas,Party
|
||||
49 Angels,Robbie Williams,Slow
|
||||
50 Hangover (Wish),Taio Cruz,Party
|
||||
51 The Real Slim Shady (Wish),Eminem,Party
|
||||
52 I don't care,,Party
|
||||
53 YMCA,Village People,Party
|
||||
54 Cotton Eye Joe (Wish),Rednex,Sex & Violins
|
||||
55 Nothing compares to you,Sinhead O' Connor,Slow
|
||||
56 Komet,Udo Lindenberg & Apache 207,Partyende
|
||||
Reference in New Issue
Block a user