server_universe_dart 0.0.13 copy "server_universe_dart: ^0.0.13" to clipboard
server_universe_dart: ^0.0.13 copied to clipboard

Server Universe Library For Help you make server rest api on cross platform support edge functions Supabase, Vercel, Netlify, cloud Flare and more

example/example.dart

// ignore_for_file: unnecessary_brace_in_string_interps

import 'dart:io';
import 'package:general_lib/extension/dynamic.dart';
import 'package:server_universe_dart/native.dart'; 

void main() async {
  print("start");
  int port = int.tryParse(Platform.environment["PORT"] ?? "3000") ?? 3000;
  String host = Platform.environment["HOST"] ?? "0.0.0.0";
  ServerUniverseNative app = ServerUniverseNative(
    logLevel: LogType.error,
    onNotFound: (request, res) async {
      return res.send(({
        "@type": "error",
        "message": "path_not_found",
        "description": "PATH: Not Found",
      }.toStringifyPretty()));
    },
  );
  app.all("/", (req, res) {
    return res.send("oke");
  });

  int count = 0;
  app.all("/version", (req, res) async {
    count++;
    return await res.status(200).send("\nCOUNT: ${count}");
  });
  await app.listen(port:port, bindIp: host);
  print("Server on");
}
17
likes
130
pub points
44%
popularity

Publisher

unverified uploader

Server Universe Library For Help you make server rest api on cross platform support edge functions Supabase, Vercel, Netlify, cloud Flare and more

Repository (GitHub)
View/report issues
Contributing

Topics

#server #socket #api #backend #network

Documentation

Documentation
API reference

Funding

Consider supporting this project:

github.com

License

MIT (LICENSE)

Dependencies

server_universe

More

Packages that depend on server_universe_dart