This repository was archived by the owner on Jul 6, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 6 files changed +15
-24
lines changed
hello-world-spa/api/counter
hello-world-src-dir/src/api/counter Expand file tree Collapse file tree 6 files changed +15
-24
lines changed Original file line number Diff line number Diff line change 11import type { APIRequest } from 'aleph/types.ts'
22
3- const store = globalThis as any
4-
53export default async function handler ( req : APIRequest ) {
6- let count = store . $ count || 0
4+ let count = parseInt ( localStorage . getItem ( ' count' ) || '0' )
75
86 switch ( req . params [ 'action' ] ) {
97 case 'increase' :
108 count ++
11- store . $ count = count
9+ localStorage . setItem ( ' count' , count . toString ( ) )
1210 req . json ( { count } )
1311 break
1412 case 'decrease' :
1513 count --
16- store . $ count = count
14+ localStorage . setItem ( ' count' , count . toString ( ) )
1715 req . json ( { count } )
1816 break
1917 default :
Original file line number Diff line number Diff line change 11import type { APIRequest } from 'aleph/types.ts'
22
3- const store = globalThis as any
4-
53export default async function handler ( req : APIRequest ) {
6- req . json ( { count : store . $count || 0 } )
4+ const count = parseInt ( localStorage . getItem ( 'count' ) || '0' )
5+ req . json ( { count } )
76}
Original file line number Diff line number Diff line change 11import type { APIRequest } from 'aleph/types.ts'
22
3- const store = globalThis as any
4-
53export default async function handler ( req : APIRequest ) {
6- let count = store . $ count || 0
4+ let count = parseInt ( localStorage . getItem ( ' count' ) || '0' )
75
86 switch ( req . params [ 'action' ] ) {
97 case 'increase' :
108 count ++
11- store . $ count = count
9+ localStorage . setItem ( ' count' , count . toString ( ) )
1210 req . json ( { count } )
1311 break
1412 case 'decrease' :
1513 count --
16- store . $ count = count
14+ localStorage . setItem ( ' count' , count . toString ( ) )
1715 req . json ( { count } )
1816 break
1917 default :
Original file line number Diff line number Diff line change 11import type { APIRequest } from 'aleph/types.ts'
22
3- const store = globalThis as any
4-
53export default async function handler ( req : APIRequest ) {
6- req . json ( { count : store . $count || 0 } )
4+ const count = parseInt ( localStorage . getItem ( 'count' ) || '0' )
5+ req . json ( { count } )
76}
Original file line number Diff line number Diff line change 11import type { APIRequest } from 'aleph/types.ts'
22
3- const store = globalThis as any
4-
53export default async function handler ( req : APIRequest ) {
6- let count = store . $ count || 0
4+ let count = parseInt ( localStorage . getItem ( ' count' ) || '0' )
75
86 switch ( req . params [ 'action' ] ) {
97 case 'increase' :
108 count ++
11- store . $ count = count
9+ localStorage . setItem ( ' count' , count . toString ( ) )
1210 req . json ( { count } )
1311 break
1412 case 'decrease' :
1513 count --
16- store . $ count = count
14+ localStorage . setItem ( ' count' , count . toString ( ) )
1715 req . json ( { count } )
1816 break
1917 default :
Original file line number Diff line number Diff line change 11import type { APIRequest } from 'aleph/types.ts'
22
3- const store = globalThis as any
4-
53export default async function handler ( req : APIRequest ) {
6- req . json ( { count : store . $count || 0 } )
4+ const count = parseInt ( localStorage . getItem ( 'count' ) || '0' )
5+ req . json ( { count } )
76}
You can’t perform that action at this time.
0 commit comments