Advertisement
Guest User

Untitled

a guest
Jul 29th, 2014
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. User = {
  2. fields: {
  3. name: {
  4. type: "STRING"
  5. },
  6. id: {
  7. type: "integer"
  8. },
  9. password: {
  10. type: "STRING"
  11. }
  12. }
  13. };
  14.  
  15. car = {
  16. fields: {
  17. model: {
  18. type: "STRING"
  19. },
  20. color: {
  21. type: "STRING"
  22. }
  23.  
  24. }
  25. };
  26.  
  27. var Model = fs.readFileSync("Model.js");
  28. data_test = JSON.stringify(Model);
  29. response.send(data_test);
  30.  
  31. function requireFromString(src, filename) {
  32. var Module = module.constructor;
  33. var m = new Module();
  34. m._compile(src, filename);
  35. return m.exports;
  36. }
  37. var moduleStr = fs.readFileSync("Model.js");
  38. moduleStr = 'module.exports = {' + moduleStr + '}';
  39. response.send(requireFromString(moduleStr));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement