GetServer는 Flutter용 백엔드 서버 솔루션으로, Flutter 구문을 사용하여 HTTP 및 WebSocket 서버를 빌드할 수 있게 해줍니다. Dart의 통합 언어를 활용해 프론트엔드와 백엔드 간에 코드 재사용을 원활하게 하여 풀스택 개발을 단순화합니다. Android, iOS, macOS, Windows, Linux 등 여러 플랫폼을 지원하며 일관된 개발 경험을 제공합니다. GetX 생태계와 자연스럽게 통합되어, 컨텍스트 전환을 최소화하고 공유 로직을 극대화하려는 프로젝트에 적합합니다.
사용 사례
풀스택 플러터 애플리케이션
클라이언트와 서버 간의 코드 재사용
WebSocket을 사용한 실시간 웹 애플리케이션
빠른 백엔드 프로토타이핑
크로스 플랫폼 서버 배포
주요 기능
서버 코드용 플러터 유사 구문
내장된 HTTP 및 WebSocket 지원
Flutter 프론트엔드와 공유 로직
다중 플랫폼 서버 배포
GetX 생태계와의 통합
적합한 대상
GetX를 사용하는 개발자
통합 코드베이스를 찾는 팀
실시간 기능이 필요한 프로젝트
빠른 백엔드 개발
크로스 플랫폼 애플리케이션 아키텍트
고려 사항
Dart/Flutter 생태계에 제한됨
생산 준비를 위해 추가 구성이 필요할 수 있습니다
전통적인 백엔드에 비해 커뮤니티 규모가 작음
비-Dart 팀에게 적합하지 않음
고부하 상황에서 성능 튜닝이 필요합니다
원본 README
연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.
Get Server
GetServer allows you to write backend applications with Flutter. Everything here is familiar, from the widgets, to the setState, initState and dispose methods, to the way you manage your projects with GetX using controllers and bindings. You don't need any additional knowledge to use GetServer, if you know Flutter, you can write your application's API using it.
GetServer gives you 100% reuse of code between backend and frontend.
Flutter has become increasingly popular, and as it grows, there is also a new need for a niche of developers who want to use the same Stack.
GetX for its ease and practicality has attracted many new developers every day, who started using Flutter to build mobile, desktop and also web applications. However, the GetX community has turned to a common need: the lack of a cohesive ecosystem for backend programming without a large learning curve.
The purpose of this project is to supply the needs of these developers, who can now build backend applications with a 0% learning curve. If you already program in another language, I invite you to test it, if you feel good, or mastered another language, maybe GetServer is not for you, but we are happy to bring ease to people's lives, so if you program mobile but you have no idea how to create an api, you may have found what you were looking for.
If you have a local database written in dart (like Hive and Sembast), you can turn it into a backend and build your api to provide them with a simple copy and paste.
All of your Model classes are reused.
All its route syntax is reused (if you use GetX)
All of your business logic is reused.
However, if you don't need to have a single page, you will need named routes to define your urls. This is stupidly simple, and identical to GetX routes for frontend
Ok, you created your project with Flutter web, and you have no idea how to host it on a VPS, would it be possible to create the API for your application, and use the same GetX to display the Flutter web project?
Yep. You need only copy your web folder from Flutter project, and paste on directory
from server file.
Flutter web generates an html file that calls a js file, which in turn requests several files that must be in a public folder. To make the Flutter web folder a public folder, just add it to your GetServer. That way when you enter your server, you will automatically be directed to site made with Flutter.
Ok, but what if I want to do a POST method to send a photo to my server, for example, how do I do this?
Okay, that sounds crazy, but you upload the file to your server, and retrieve it with an "upload.data".
For the example not to be small, I will return a json response with the name of the file, his mimeType, and the same file back decoded in base64 so the example doesn't have just 5 lines.
Dart is not popular for servers, however, attracting people who already program in Flutter to the backend is now also a mission of GetX. Transforming one-dimensional programmers into full stack developers with 0% learning curve, and reusing code is also one of GetX's goals, and I hope you will help us on this journey.
The CI with Get Server is easy, you can write a file with the content above and put in .github/workflows/main.yml and then you will have as artifacts, your server's binary compilation for linux/windows/mac with each merge.
name:CIBuildingnativeserveron:# Triggers the workflow on push or pull request events but only for the main branchpush:branches: [ main ]
pull_request:branches: [ main ]
# Allows you to run this workflow manually from the Actions tabworkflow_dispatch:jobs:build:runs-on:${{matrix.os}}strategy:matrix:os: [ubuntu-latest, windows-latest, macOS-latest]
include:-os:ubuntu-latestoutput-name:server-linux-os:macOS-latestoutput-name:server-mac-os:windows-latestoutput-name:server-windows.exesteps:-uses:actions/checkout@v2-uses:dart-lang/setup-dart@v1.3-name:Installdependenciesrun:dartpubget-run:mkdirbuild-name:InstallDependenciesrun:dartpubget-run:dartcompileexe./lib/main.dart-v-obuild/${{matrix.output-name}}-uses:actions/upload-artifact@v1with:name:native-executablespath:build
Like most of the "node.js" way?
The purpose of this package is to make development for Flutter developers easier. However, the javascript ecosystem is very large and you may be used to a more functional syntax.
With get_server you can use this path. You can use get_server as well:
import'package:get_server/get_server.dart';
voidmain() {
final app = GetServer();
app.get('/', (ctx) => Text('Get_server of javascript way'));
app.ws('/socket', (ws) {
ws.onMessage((data) {
print('data: $data');
});
ws.onOpen((ws) {
print('new socket opened');
});
ws.onClose((ws) {
print('socket has been closed');
});
});
}
More Power
If you host your Getserver on a cheap server with few cores, the default option is more than enough. However, if you have a server with many cores and want to make the most of it, you can start the multithreaded server with isolates. This requires only a small step.
Create a global function (isolated requirement), insert your runApp into it, and start it in runIsolate.
Note: This is a function that creates a thread for each CPU and you can use it throughout your application with GetServer. If you need activity with intense CPU and memory activity, you can use runIsolate.
How can you help?
Creating Pull requests, adding resources, improving documentation, creating sample applications, producing articles, videos about Getx, suggesting improvements, and helping to disseminate this framework in development communities.
Supporting this project.
TODO:
~Add Auth options~
~Remove requirements dart:mirrors to allow people to compile the server and use only the binary, protecting its source code.~
~Creation of Bindings and Controllers (as in the main GetX) to adapt the project 100% with Getx for frontend.~
Add some ORM
Accessing GetX:
GetX starts by default on port 8080.
This was done to, if you want to install a reverse proxy like nginx, do it without much effort.
You could, for example, access the home page created in this example, using:
http://localhost:8080/
or
http://127.0.0.1:8080/
However, if you want to start it on another port, such as 80, for example, you can simply do: