-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dd08d0d
commit bb18bed
Showing
35 changed files
with
261 additions
and
246 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
APP_PORT=3001 | ||
APP_PORT=3003 | ||
APP_KEY=KKep5qC6uHlAgrwaQTQewgMRSIqQnoj0 | ||
|
||
DB_HOST=localhost | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,51 @@ | ||
import 'package:dox_app/config/cache.dart'; | ||
import 'package:dox_app/config/cors.dart'; | ||
import 'package:dox_app/config/services.dart'; | ||
import 'package:dox_app/config/storage.dart'; | ||
import 'package:dox_app/http/handler.dart'; | ||
import 'package:dox_app/http/requests/blog.request.dart'; | ||
import 'package:dox_app/routes/api.dart'; | ||
import 'package:dox_app/routes/web.dart'; | ||
import 'package:dox_app/routes/websocket.dart'; | ||
import 'package:dox_core/cache/drivers/file/file_cache_driver.dart'; | ||
import 'package:dox_core/dox_core.dart'; | ||
|
||
class Config extends AppConfig { | ||
@override | ||
int get totalIsolate => 6; | ||
|
||
@override | ||
String get appKey => Env.get('APP_KEY'); | ||
|
||
@override | ||
int get serverPort => int.parse(Env.get('APP_PORT', 3000)); | ||
|
||
@override | ||
Map<Type, Function()> get formRequests => <Type, Function()>{ | ||
BlogRequest: () => BlogRequest(), | ||
}; | ||
|
||
@override | ||
List<dynamic> get globalMiddleware => <dynamic>[ | ||
// LogMiddleware(filter: logFilter, withHeader: true), | ||
]; | ||
|
||
@override | ||
List<Router> get routers => <Router>[ | ||
WebRouter(), | ||
ApiRouter(), | ||
WebsocketRouter(), | ||
]; | ||
|
||
@override | ||
CORSConfig get cors => CORSConfig( | ||
allowOrigin: '*', | ||
allowHeaders: '*', | ||
allowMethods: '*', | ||
allowCredentials: true, | ||
exposeHeaders: '*', | ||
); | ||
@override | ||
CacheConfig get cacheConfig => CacheConfig( | ||
drivers: <String, CacheDriverInterface>{ | ||
'file': FileCacheDriver(), | ||
}, | ||
); | ||
|
||
@override | ||
ResponseHandlerInterface get responseHandler => ResponseHandler(); | ||
|
||
// @override | ||
// void Function(Object? error, StackTrace stackTrace) get errorHandler => | ||
// (Object? error, StackTrace stackTrace) { | ||
// DoxLogger.prettyLog( | ||
// 'error', | ||
// error.toString(), | ||
// stackTrace.toString(), | ||
// ); | ||
// }; | ||
} | ||
AppConfig appConfig = AppConfig( | ||
/// application key | ||
appKey: Env.get('APP_KEY'), | ||
|
||
/// application server port | ||
serverPort: int.parse(Env.get('APP_PORT', 3000)), | ||
|
||
/// total multi-thread isolate to run | ||
totalIsolate: 6, | ||
|
||
/// global middleware | ||
globalMiddleware: <dynamic>[], | ||
|
||
/// form requests | ||
formRequests: <Type, FormRequest Function()>{ | ||
BlogRequest: () => BlogRequest(), | ||
}, | ||
|
||
/// routers | ||
routers: <Router>[ | ||
WebRouter(), | ||
ApiRouter(), | ||
WebsocketRouter(), | ||
], | ||
|
||
/// response handler | ||
responseHandler: ResponseHandler(), | ||
|
||
/// service to run on multithread server | ||
services: services, | ||
|
||
/// cors configuration | ||
cors: cors, | ||
|
||
/// cache driver configuration | ||
cache: cache, | ||
|
||
/// file storage driver configuration | ||
fileStorage: storage, | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import 'package:dox_core/cache/drivers/file/file_cache_driver.dart'; | ||
import 'package:dox_core/dox_core.dart'; | ||
|
||
CacheConfig cache = CacheConfig( | ||
/// default cache driver | ||
defaultDriver: Env.get('CACHE_DRIVER', 'file'), | ||
|
||
/// register cache driver list | ||
drivers: <String, CacheDriverInterface>{ | ||
'file': FileCacheDriver(), | ||
}, | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import 'package:dox_core/dox_core.dart'; | ||
|
||
CORSConfig cors = CORSConfig(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import 'package:dox_app/services/auth_service.dart'; | ||
import 'package:dox_app/services/database_service.dart'; | ||
import 'package:dox_app/services/websocket_service.dart'; | ||
import 'package:dox_core/dox_core.dart'; | ||
|
||
List<DoxService> services = <DoxService>[ | ||
DatabaseService(), | ||
AuthService(), | ||
WebsocketService(), | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import 'package:dox_core/dox_core.dart'; | ||
import 'package:dox_core/storage/local_storage_driver.dart'; | ||
|
||
FileStorageConfig storage = FileStorageConfig( | ||
/// default storage driver | ||
defaultDriver: Env.get('STORAGE_DRIVER', 'local'), | ||
|
||
// register storage driver list | ||
drivers: <String, StorageDriverInterface>{ | ||
'local': LocalStorageDriver(), | ||
}, | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
packages/dox-core/lib/interfaces/response_handler_interface.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
import 'package:dox_core/dox_core.dart'; | ||
|
||
abstract class ResponseHandlerInterface { | ||
const ResponseHandlerInterface(); | ||
|
||
dynamic handle(DoxResponse res); | ||
} |
Oops, something went wrong.